You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/content/posts/hugo-github-pages-starter/index.md
+29-7
Original file line number
Diff line number
Diff line change
@@ -130,15 +130,34 @@ services:
130
130
- ./site:/site
131
131
ports:
132
132
- 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
134
135
```
135
136
136
137
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.
137
138
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
+
```
139
150
140
151
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:
141
152
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.
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:
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.
246
262
247
263
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)
248
264
249
265
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.
250
266
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.
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".
Once you are happy, make sure you perform a commit and push to sync the newly created site to your repo.
252
274
253
275
> 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.
0 commit comments