A small Bash script to quickly build your Hugo website and commit the changes.
| commit.sh | add scripts | |
| HugoCommit.sh | update script, README | |
| LICENCE.md | add licence | |
| README.md | update script, README | |
HugoCommit.sh
The archaic way
Assume, you’ve got a Hugo website. In order to publish an update to Codeberg Pages for example, you have to
- run hugo
- Git-commit your changes in the Hugo repo
- Git-push the Hugo repo to Codeberg
- Git-commit your changes in the
pagerepo - Git-push the
pagerepo to Codeberg Pages
$ hugo
$ hugo serve
$ git add .
$ git commit
$ git push origin master
$ cd ../../page
$ git add .
$ git commit
$ git push origin master
The modern way
HugoCommit.sh does all that automatically for you! You just have to execute the script in the command line and let the magic happen!
Build your Hugo: $ bash HugoCommit.sh
Live demo: $ bash HugoCommit.sh serve
Commit and push: $ bash HugoCommit.sh commit
Setup
- Set an
outputDirin your Hugo configuration file. Currently, it must be namedconfig.yaml. - In the output directory, initialise a Git repository.
- Copy
HugoCommit.shandcommit.shto your Hugo project folder. - Install
trash-cliandcoreutils:$ sudo apt-get install trash-cli coreutils
Your project’s file structure should look something like this:
<Website project folder>
│
├─ <Main Git repo>
│ │
│ ├─ <Hugo project folder>
│ │ │
│ │ ├─ archetypes
│ │ ├─ assets
│ │ ├─ content
│ │ ├─ data
│ │ ├─ layouts
│ │ ├─ themes
│ │ │
│ │ ├─ config.yaml
│ │ ├─ HugoCommit.sh
│ │ └─ commit.sh
│ │
│ └─ .git
│
└─ <PublishDir Git repo>
└─ .git
Licence
You may freely use HugoCommit’s source code according the MIT licence (slightly modified). A link to my repo as the original source would be great 😎