Inspired by Network Chuck's efforts. However, I prefer having certain tools containerized.
The Dockerfile has everything we need to develop our hugo-website with both golang and hugo.
Video if you're interested: https://youtu.be/KnjFVtHJuXU
This requires you to have both Python and Docker installed on your machine.
Click Use This Template at BadgersHugoTemplate.
Clone your newly created repo using this template. The <> Code button has a dropdown menu with the various
options available for cloning.
There should be 3 Github actions that start running.
- Initial Setup (this should pass. It updates our compose.yml and config.json with our repository info - otherwise it keeps the template info)
- Deploy Site (this should fail because we don't have a website directory yet)
- Docker Image CI (this should hopefully pass? It's possible the Initial Setup needs to finish first before this passes)
Reason why Initial Setup and Docker Image CI are separate is because the Initial Setup workflow is no longer needed once it passes the first time.
Feel free to delete the validate.yml once the action is complete.
Everything is set via config.json. There are some reasonable defaults which follows NetworkChuck's video. It is worth noting
if you're deploying to GitHub pages you need to change the baseUrl to be whatever your repository name is. For instance, for me, I have
to put /BadgersBlog - because that's the repo name I'm using for my blog. Not doing this will result in some weirdness such as
- Paths not working
- Themes! Themes won't work properly! You'll have content, but it won't look.... pretty
How to get started:
Confirm the things in the config.json are okay then run the setup script with the --init flag.
python ./setup.py --initNow, for the most part, you only have to worry about adding content to your posts directory (website/content/posts)
Feel free to navigate to http://localhost:1313 to validate everything is working. Otherwise, we're ready to
commit!
git add .
git commit -m "Some message you want"
git push origin masterThis should kick off a GitHub action! When it finishes you should have a new branch github-pages.
On GitHub, go to your repo settings -> Pages.
Select the branch github-pages and hit save! This should kick off another GitHub action which deploys
your static site!
That's it! Now anytime you upload new content your GitHub pages will stay in sync!
There are three values required per theme you want to try/install. The name, GitHub Url, and the golang module name.
The setup script will automatically initialize your submodules, add the theme where it needs to go and update the
.env to specified theme name. It then restarts the container so the theme changes take over.
Note: You may have to verify the hugo.toml file within the website directory. For terminal, it's included for
convenience and automatically pulled in if used.
Terminal (Default Theme) just like NetworkChuck.
If you have multiple themes and would like to swap between them, use --theme argument. This will update the .env and
restart the container.
python ./setup.py --theme terminalGo to http://localhost:1313 and you should see content! As you make changes to your markdown files you should see your changes in near-real-time.
If you aren't trying to configure anything, and want to manage the container
Start container:
docker compose up -dStop container:
docker compose down