How to make this website

I am rebuilding this site. This site did not use Hugo’s theme functionality properly. Instead of using a theme folder and overriding it as necessary, I just had everything in one big monorepo. Applying patches from upstream themes became painful. It also made things difficult for people who wanted to copy my theme. To correct that, I am rebuilding the whole site, this time using with the theme and site in separate repositories, the way I should have in the first place. This post documents the process and serves to help people who may want to do something similar.

Creating the theme

To start, I create an empty git repository, with branches to track Munif Tanjim’s Minimo1 theme and achary’s Enigmo2 theme. Then I merge Minimo into master to start off with a fresh copy of it.

# Create the repo and push an initial commit
git init geronimo
cd geronimo
touch LICENSE
git add LICENSE
git commit -m "initial commit"

# Add a branch to track Minimo
git checkout -b minimo
git remote add minimo https://github.com/MunifTanjim/minimo.git
git fetch minimo master
git branch --set-upstream-to=minimo/master

# Add a branch to track Enigmo
git checkout -b enigmo
git remote add enigmo https://github.com/achary/engimo.git
git fetch enigmo master
git branch --set-upstream-to=enigmo/master

# Finally, merge Minimo into the master branch and push it to the repo
git checkout master
git merge minimo/master --allow-unrelated-histories
git remote add origin [email protected]:brian/geronimo.git
git push --set-upstream origin master

Creating the site

After creating the base theme, I create a repository for the site itself.

# Create a Hugo site skeleton and initialize git tracking in it
hugo new site tiuxo.com
cd tiuxo.com
git init
git add *
git commit -a -m "initial commit"

# Add the theme as a submodule
git submodule add https://git.tiuxo.com/brian/geronimo themes/geronimo
git submodule update --init themes/geronimo

# Configure git large file storage
git lfs install
git config lfs.https://ssh.git.tiuxo.com/brian/tiuxo.com.git/info/lfs.locksverify true

git remote add origin [email protected]:brian/tiuxo.com.git
git push --set-upstream origin master

In the next commit, I use the default settings from the Minimo demonstration site’s config.toml to create a bare bones configuration. Instead of using a single config.toml, I use a config/_default directory with yaml files. The separate files are a bit more organized, and I dislike toml files.

Configuring automatic deployment

To test and deploy the site, I use Drone. The Drone script tests that the site builds without error, then send commands to the webserver to update it’s own copy and build it. /srv/www/sites/www.tiuxo.com is the git repository, and nginx is configured to serve the public directory within.

kind: "pipeline"
name: "default"

steps:
  - name: "fetch submodules"
    image: "alpine/git"
    commands:
      - "git submodule update --init --recursive --remote"

  - name: "test"
    image: "plugins/hugo"
    settings:
      hugo_version: "0.59.1"
      url: "https://tiuxo.com"
      validate: true

  - name: "deploy"
    image: "appleboy/drone-ssh"
    settings:
      host:
        from_secret: "ssh_host"
      username:
        from_secret: "ssh_user"
      key:
        from_secret: "ssh_key"
      timeout: 2m
      command_timeout: 10m
      script:
        - "cd /srv/www/sites/www.tiuxo.com"
        - "git fetch --depth=1"
        - "git reset --hard origin/master"
        - "git submodule update --init --recursive --remote"
        - "hugo"
    when:
      branch:
        - "master"
      event:
        exclude:
          - "pull_request"

The relevant nginx configuration when using the DebOps nginx role is quite simple. I could also have used the redirect_from key in the www.tiuxo.com server entry, but I have some unlisted services running under the tiuxo.com server.

nginx__servers:
  - name: "tiuxo.com"
    ssl_crt: "/etc/letsencrypt/live/tiuxo.com/fullchain.pem"
    ssl_key: "/etc/letsencrypt/live/tiuxo.com/privkey.pem"
    redirect: "https://www.tiuxo.com$request_uri"
    redirect_ssl: "https://www.tiuxo.com$request_uri"
    redirect_code: "301"
  - name: "www.tiuxo.com"
    deny_hidden: false
    maintenance: false
    ssl_crt: "/etc/letsencrypt/live/www.tiuxo.com/fullchain.pem"
    ssl_key: "/etc/letsencrypt/live/www.tiuxo.com/privkey.pem"

  1. “Minimo theme” Munif Tanjim GitHub [return]
  2. “Enigmo theme” achary GitHub [return]