Skip to content

Commit 5938082

Browse files
0.1.0 development
1 parent 781fb21 commit 5938082

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed
Loading
Loading

site/content/posts/hugo-github-pages-starter/index.md

+29-7
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,34 @@ services:
130130
- ./site:/site
131131
ports:
132132
- 1313:1313
133-
command: hugo server --bind 0.0.0.0 --disableFastRender
133+
# command: hugo server --bind 0.0.0.0 --disableFastRender
134+
stdin_open: true
134135
```
135136
136137
From here, execute `"docker compose up"` to start up your hugo development server. You will notice that it will fail the first time because we have not created a new Hugo site yet.
137138
138-
> output here
139+
```bash
140+
❯ sudo docker compose up
141+
[+] Running 1/1
142+
✔ Container hugo-git-pages-starter-hugo-1 Created
143+
Attaching to hugo-1
144+
145+
^CGracefully stopping... (press Ctrl+C again to force)
146+
[+] Stopping 1/1
147+
✔ Container hugo-git-pages-starter-hugo-1 Stopped
148+
canceled
149+
```
139150

140151
To fix this, we can simply navigate to the site directory `"cd site"` and execute `"hugo new site ."` inside our container which will create the initial files and reflect them back to our local machine as we are using the Docker Compose volume mounting functionality. From here you can quit out of the container and execute `"docker compose down"` and `"docker compose up"` again and we should now have the development server up and running:
141152

153+
```bash
154+
❯ docker compose exec hugo /bin/bash
155+
root@ee56131712df:/site#
156+
root@ee56131712df:/site# hugo new site .
157+
Congratulations! Your new Hugo site was created in /site.
158+
159+
```
160+
142161
```bash
143162
hugo-1 | Built in 52 ms
144163
hugo-1 | Environment: "development"
@@ -237,18 +256,21 @@ ENV PATH="/var/hugo/bin:$PATH"
237256

238257
Perform a git commit & push so these files are uploaded to our repository. From here navigate to [codespaces](https://github.com/codespaces), select "New Codespace" and then select your repository. The rest of the settings should default to something like the below:
239258

240-
- Branch: Main
241-
- Dev container configuration: Hugo Dev Container
242-
- Region: (your region)
243-
- Machine Type: 2-Core
259+
<img src="./images/hugo-codespace-1.png" alt="Codespaces GUI image">
244260

245261
If everything looks good, click "Create Codespace", which should open up a new browser tab with a web version of Visio Studio Code with your repo ready to go.
246262

247263
You may see an error on first setup as we haven't installed a theme yet, but we will cover that next. As with the other methods, from the provided terminal enter the site directory `"cd site"` and initialize your site using the `"sudo hugo new site ."` command (you don't need to do this if you've used one of the other methods already)
248264

249265
From here click the top bar or press <kbd><kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>P</kbd></kbd> and select/type "Run Task" and then "Run Hugo Server" which should start up your Hugo server.
250266

251-
In the ports tab you can simply click the globe icon next to the forwarded port and that should open up an additional tab which will display your Hugo website. Once you are happy, make sure you perform a commit and push to sync the newly created site to your repo.
267+
<img src="./images/hugo-codespace-2.png" alt="Codespaces GUI image">
268+
269+
In the ports tab you can simply click the globe icon next to the forwarded port and that should open up an additional tab which will display your Hugo website. As we have no content yet it will display "Page not found".
270+
271+
<img src="./images/hugo-codespace-3.png" alt="Codespaces GUI image">
272+
273+
Once you are happy, make sure you perform a commit and push to sync the newly created site to your repo.
252274

253275
> Note: Whenever you are done with developing, you can press <kbd><kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>P</kbd></kbd> and type "Stop current codespace" to stop the codespace, or just close the tab and then stop the codespace from the [codespaces](https://github.com/codespaces) page.
254276
</details>

0 commit comments

Comments
 (0)