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
+38-9
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,6 @@ Now, using your development environment of choice clone your newly created repos
52
52
# Hugo gitignores
53
53
/site/resources/
54
54
/site/public/
55
-
/site/themes/
56
55
.hugo_build.lock
57
56
```
58
57
@@ -79,7 +78,7 @@ Once installed, navigate to the previously created site directory and execute `"
79
78
80
79
<details>
81
80
<summary>Expand / Collapse</summary>
82
-
If using docker, create a Dockerfile file and docker-compose.yml file in the base directory of your repository with the below content (or simply copy these files in my basic-github-hugo-blog repo). You can change the HUGO_VERSION environment variable to the latest of whatever you want.
81
+
If using docker, create a Dockerfile file and docker-compose.yml file in the base directory of your repository with the below content (or simply copy these files in my basic-github-hugo-blog repo). You can change the HUGO_VERSION environment variable to the latest or whatever you want.
83
82
84
83
```bash
85
84
~/Dockerfile
@@ -134,30 +133,60 @@ services:
134
133
stdin_open: true
135
134
```
136
135
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.
136
+
For our first run, we comment out the command and have `stdin_open: true` uncommented as our server will not run until we've created the initial site and the container will automatically be stopped.
137
+
138
+
In a terminal window execute `"sudo docker compose up"` to start up your hugo development server. You will notice that it sit at "Attaching to hugo-1" which will allow us to get into a bash shell on the server and create our site.
138
139
139
140
```bash
140
141
❯ sudo docker compose up
141
142
[+] Running 1/1
142
143
✔ Container hugo-git-pages-starter-hugo-1 Created
143
144
Attaching to hugo-1
145
+
```
144
146
147
+
In a different terminal window, you can now execute `"sudo docker compose exec hugo /bin/bash"` to get into our running container, and then execute `"hugo new site ."` to build our initial files and reflect them back to our local machine as we are using the Docker Compose volume mounting functionality.
148
+
149
+
```bash
150
+
❯ sudo docker compose exec hugo /bin/bash
151
+
root@ee56131712df:/site#
152
+
root@ee56131712df:/site# hugo new site .
153
+
Congratulations! Your new Hugo site was created in /site.
154
+
```
155
+
156
+
Once done we can stop our running compose by pressing <kbd><kbd>CTRL</kbd>+<kbd>C</kbd></kbd> and then edit our `docker-compose.yml` file and uncomment the command line and comment the stdin_open line.
157
+
158
+
```bash
145
159
^CGracefully stopping... (press Ctrl+C again to force)
146
160
[+] Stopping 1/1
147
161
✔ Container hugo-git-pages-starter-hugo-1 Stopped
148
162
canceled
149
163
```
150
164
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:
165
+
As the container runs as root, the files that were synced via the volume functionality will be owned by root and won't be editable on your local machine. To fix this we can just do a `"sudo chown -R user:user *"` to recursively set the owner of these files to whatever username you are using on your local machine
152
166
153
167
```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.
168
+
❯ cd site
169
+
❯ ls -lah
170
+
total 48K
171
+
drwxr-xr-x 11 ajones ajones 4.0K Mar 26 20:24 .
172
+
drwxr-xr-x 7 ajones ajones 4.0K Mar 25 21:18 ..
173
+
drwxr-xr-x 2 root root 4.0K Mar 25 21:34 archetypes
174
+
drwxr-xr-x 2 root root 4.0K Mar 25 21:34 assets
175
+
drwxr-xr-x 2 root root 4.0K Mar 25 21:34 content
176
+
177
+
❯ sudo chown -R ajones:ajones *
178
+
❯ ls -lah
179
+
total 48K
180
+
drwxr-xr-x 11 ajones ajones 4.0K Mar 26 20:24 .
181
+
drwxr-xr-x 7 ajones ajones 4.0K Mar 25 21:18 ..
182
+
drwxr-xr-x 2 ajones ajones 4.0K Mar 25 21:34 archetypes
183
+
drwxr-xr-x 2 ajones ajones 4.0K Mar 25 21:34 assets
184
+
drwxr-xr-x 2 ajones ajones 4.0K Mar 25 21:34 content
158
185
159
186
```
160
187
188
+
Run `"sudo docker compose up"` again and we should now see the below.
189
+
161
190
```bash
162
191
hugo-1 | Built in 52 ms
163
192
hugo-1 | Environment: "development"
@@ -277,7 +306,7 @@ Once you are happy, make sure you perform a commit and push to sync the newly cr
277
306
278
307
### Tailwind theme installation
279
308
280
-
Now that your Hugo development environment is setup, you can install the Tailwind theme. To do this navigate to the root directory of our Hugo site (~/site) and add the Tailwind theme as a Git submodule
309
+
Now that your Hugo development environment is setup, you can install the Tailwind theme. To do this navigate to the root directory of your Hugo site (~/site) and add the Tailwind theme as a Git submodule
0 commit comments