Blogdown

liva-hugo theme and some automation

In the previous post I introduced a quick exploration into the theme identified as hugo-creative-portfolio-theme. This added some figures and some great new understanding as to how hugo works - I have now gone one step further and have again a new favourite hugo theme. The canonical theme can be browsed here - installing into blogdown is as simple as … (yes - I started with a clean install to vanish some of the fluff from the last couple of days).

blogdown::new_site(theme="gethugothemes/liva-hugo")

I repopulated the couple of posts prepared yesterday and we have shuffled around the location for the figures that have been included. Some modification of the html code included in the theme has been performed to sharpen the pages and to make them a little more to my liking.

One of the major differences for the liva-hugo theme is that in addition to the ‘normal’ blog posts there is a concept of type: "featured" so that some posts can be pinned to the landing page - w00t! This feature will require a bit of moderation but is useful for highlighting some of the more salient content. I am also feeling that the concept of post categorisation is going to be super- useful over the coming posts!

For these webpages I chose the useful sagrudd.github.io URL. This is hosted as a GitHub Pages site - this provides rather limited opportunities in how the site code and the presentation content are separated

In Amber Thomas post, she introduces a solution where the code side of the webpage is placed in one GitHub branch (canonically called hugo) whilst the content rendered by the hugo software is stored in the master branch. The master and hugo branches are then linked using git subtree functionality. This seems sufficient for my purposes …

Amber introduces a couple of trivial scripts to shepherd the data in the right directions; her examples were a couple of years old and not quite contemporary - I have taken the liberty to update the code to work for me.

#!/usr/bin/env bash
# This script allows you to easily and quickly generate and deploy your website
# using Hugo to your personal GitHub Pages repository. This script requires a
# certain configuration, run the `setup.sh` script to configure this. See
# https://hjdskes.github.io/blog/deploying-hugo-on-personal-github-pages/index.html
# for more information.
# Set the English locale for the `date` command.
export LC_TIME=en_US.UTF-8
# GitHub username.
USERNAME=sagrudd
# Name of the branch containing the Hugo source files.
SOURCE=hugo
# The commit message.
MESSAGE="Site rebuild $(date)"
msg() {
    printf "\033[1;32m :: %s\n\033[0m" "$1"
}
msg "Pulling down the \`master\` branch into \`public\` to help avoid merge conflicts"
git subtree pull --prefix public https://github.com/$USERNAME/$USERNAME.github.io.git master -m "Merge origin master"
msg "Building the website"
hugo
sleep 5s
msg "Pushing the updated \`public\` folder to the \`$SOURCE\` branch"
git add public
git commit -m "$MESSAGE"
git push
msg "Pushing the updated \`public\` folder to the \`master\` branch"
git subtree push --prefix public https://github.com/$USERNAME/$USERNAME.github.io.git master

It’s a bit of a hack, but if you are reading this post - it seems to work!