After a few false starts I have finally got my Hugo site setup to use git submodule to push the HTML output to the remote webserver.

It was a little involved at first, but once I got my head around the idea of a git repo within a git repo, not being a git repo but rather just a folder marked as a submodule of some parent module… you get the idea. A confusing concept that is simple and sounds simple, but isn’t explained particularly well in any article I found.

Basically I have Git setup on my local Hugo folder and then I set up a submodule on the /public/ folder in the Hugo folder. Then I can just push the /public/ directory to my webserver host. Works well on first testing, time will tell though in the long ter. Another push and all seems to be working now.

The command to push to the remote server is this:

git subtree push --prefix=<submodule name> ssh://<user>@c<domain>/<remote git folder> <branch>

This is using SSH and I have a script in the *hooks folder, set up to copy the pushed files over to live directory on the web-server.

I might write a post on that later, as helps me remember how it is done.