Skip to content

Commit a74acf5

Browse files
0.1.0 development
1 parent 5938082 commit a74acf5

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Hugo gitignores
22
/site/resources/
33
/site/public/
4-
/site/themes/
54
.hugo_build.lock

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

+38-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ Now, using your development environment of choice clone your newly created repos
5252
# Hugo gitignores
5353
/site/resources/
5454
/site/public/
55-
/site/themes/
5655
.hugo_build.lock
5756
```
5857

@@ -79,7 +78,7 @@ Once installed, navigate to the previously created site directory and execute `"
7978

8079
<details>
8180
<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.
8382

8483
```bash
8584
~/Dockerfile
@@ -134,30 +133,60 @@ services:
134133
stdin_open: true
135134
```
136135
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.
138139

139140
```bash
140141
❯ sudo docker compose up
141142
[+] Running 1/1
142143
✔ Container hugo-git-pages-starter-hugo-1 Created
143144
Attaching to hugo-1
145+
```
144146

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
145159
^CGracefully stopping... (press Ctrl+C again to force)
146160
[+] Stopping 1/1
147161
✔ Container hugo-git-pages-starter-hugo-1 Stopped
148162
canceled
149163
```
150164

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
152166

153167
```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
158185
159186
```
160187

188+
Run `"sudo docker compose up"` again and we should now see the below.
189+
161190
```bash
162191
hugo-1 | Built in 52 ms
163192
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
277306

278307
### Tailwind theme installation
279308

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
281310

282311
```bash
283312
git submodule add https://github.com/tomowang/hugo-theme-tailwind.git themes/tailwind

0 commit comments

Comments
 (0)