Hello, I'm Raimonster

Human being and software developer

This site

2 minutes
August 21, 2019

Intro

Second time setting up a static site with hugo and it starts looking better already.

Apparently hugo uses 2 types of pages: List and Single pages. Homepage is a bit different than others. It is technically a List page, and it can have its own template at layouts/index.html.

And the render flow goes from layout, to the page you are looking at.

To find out what happens when rendering, look at the lists example and the lookup order in those docs:

Loading of templates

Here’s my understanding of the templating stuff as of today 2019-09-03:

In your content tree you have directories (e.g. /content/foo/). hugo renders http://yourdomain.com/foo using _index.md files, cascading from /themes/used-theme/_layouts/foo/_index.md, /layouts/foo/_index.md, and finally /content/foo/_index.md.

From one to the next you can “yield” (in rails parlance) using {{.Content}}.

Homepage is a bit special.

Code snippets

https://gohugo.io/content-management/syntax-highlighting/

https://gohugo.io/templates/shortcode-templates/

    local foo = bar
    for k, v in map(t) do
      print(k, v)
    end

To highlight code, use this shortcode (delete the marked whitespaces)

{{ < highlight lua >}}
--^
    local foo = bar
    for k, v in map(t) do
      print(k, v)
    end
--v
{{ < /highlight >}}
--^
    local foo = bar
    for k, v in map(t) do
      print(k, v)
    end
--v

Tags

Adding tags in the theme I’m using.

Deploy

I started by hosting this site in a server of my own, with a dead simple Makefile that scp’d the /public directory. But if the site is 100% static, I then moved it to github pages. If you want to use a custom domain, you have to take steps further, that even if they are trival, if you do them once every 2 years, you inevitably foret them.

Cloudflare

For DNS and SSL.

git subtree

so this site is hosted in a repo ‘personal-site’, where the root of the hugo site is the root of the repo.

As the /public directory is what I want published in kidd.github.io, I created a subtree from that dir:

git subtree add --prefix=public [email protected]:kidd/kidd.github.io.git master

Then, when running hugo, the /public repo gets populated. Usual commit into personal-site (which commits the changes in the current repo), and then

git subtree push --prefix=public [email protected]:kidd/kidd.github.io.git master

To actually publish it. Here’s some info on subtrees.