How I update this site
In my last post I described how the server was set up for this very site itself. In this post, I will be describing how I create new content for the site from client devices.
How I create/update content on this site from a desktop
Required software
- ssh-keygen
- git (download here)
Instructions
- Run ssh-keygen and copy the public key into your github account’s keys section. (tutorial here)
- In the directory on the client which you want the repo stored run:
$ git clone --recursive git@github.com:jamesdesmond/james-blog.git
(replacing my git URL with yours)- the
--recursive
here is important, if you usegit submodule
s to add themes, then you need to add recursive so that the themes are also pulled, otherwise the website will fail to display anything as the theme files are missing.
- the
- Install
hugo
on your client machine. Here are the Hugo docs. I recommend the “Quick Install Binary (Cross Platform option) - In the cloned repository, run
hugo server -D
which will create a local webserver at localhost:1313. The -D flag enables drafts to be generated and shown. Which is useful. - In a new terminal windows, in the cloned repository, run
hugo new posts/test-post.md
- Make edits and save
test-post.md
, hugo server should catch the new content and refresh the local server. Check to see that your changes made it there. - Once you are happy with the content and wish to public it, make sure
draft:true
is changed tofalse
and then git add, commit, and push to the master branch to push the changes live.
This method is nice because the page is easily viewable through the localhost server, however it does require control and permissions on the client. In the case that I am on a device which I cannot install git on, I will use the github web client. By just adding a new .md file into the content/posts folder, I can update the site. Github has a viewer for Markdown files, which is not live, but is an alright alternative. I then commit and push from the web ui itself, and watch the changes propagate to my live website.