A little while back, I mentioned that I ditched WordPress for Hugo. I like the change. There’s something about a folder of markdown files that get quickly converted into nice HTML that I can upload that I like. However, one hiccup that I did have was figuring out the best way to push changes to my site. Using FTP and having to compare each file seemed unnecessary, and I was sure there was a better way. Git would have been perfect, but my cheap webhost doesn’t have it, so I had to find an alternative.
Here’s what I found, partly for sharing, and partly to help me remember in case I forget how I do these things.
The solution I found was to use git-ftp, a “Git powered FTP client written as shell script.”
So now, the approach I use is the following:
- I start off in the folder where the local copy of all of my website files are stored.
- I run
hugo new post/new_file_name.mdto create a skeleton markdown file to work with.
- Once the article is complete, I run
hugoto process the markdown and generate the HTML (or optionally,
hugo serverif I wanted to preview changes as I worked on the file).
Once the article is written, it’s time to push it to my website. This is done with the following:
- I switch over to the “public” folder of my local website copy. This is where hugo places the HTML versions of my posts.
- Usually, I then run
git statusto see what has been affected.
- I run
git add .to add all the new files, and then
git commit -am "Message"to commit the files.
- Finally, I upload everything with
git ftp push --user USERNAME --passwd PASSWORD ftp://host.example.com/public_html(replacing with my actual values, of course).
All together now:
hugo new post/new_file_name.md atom content/post/new_file_name.md hugo cd public/ git add . git commit -am "Message" git ftp push --user USERNAME --passwd PASSWORD ftp://host.example.com/public_html