Hugo Tips
Like my previous post of Zola tips, having migrated to Hugo, I’ll document here anything I find that I’ve needed to research or do to make Hugo do something I’ve wanted.
Literal Hugo shortcodes in markdown
Inevitably I will write as much about Hugo as I write about anything else. I will therefore, as in this post, want to show literal shortcodes and other things that Hugo will try to interpret. To write something like {{< some_short_code ... >}} you need to add additional markup so Hugo’s build doesn’t try to actually run the shortcode. This post is even more awkward, because I now need to write the escaped version of the shortcode verbatim…
What you need to write in your markdown to show {{< some_short_code ... >}} is:
{{</* some_short_code ... */>}}
Incidentally, what I wrote to be able to show the comment syntax just above is:
{{</*/* some_short_code ... */*/>}}
Effectively, in your markdown you need one more set of /*, */ than you want displayed in your post.
Linking to other posts
Linking to other posts isn’t difficult. E.g. to link to this post I could use the following markdown, [Hugo tips](/posts/hugo-tips). However, what if I wrote /posts/huggo-tips (typo)? That’s a broken link and I wouldn’t notice. You can use the relref shortcode instead, and that will verify the link is valid at build time, preventing the build if it is not.
[Hugo tips]({{< relref "posts/hugo-tips" >}})
Now, if you get it wrong, you’ll see an error like the following in the console.
ERROR [en] REF_NOT_FOUND: Ref “posts/huggo-tips”
Be aware that if you link to a draft, using hugo serve for example will error,
because the drafts aren’t being built.
Full content in RSS feed
By default Hugo’s RSS feed only includes article summaries. That’s fine if that’s your thing, but I want the full content in there. Fortunately, I’m not the only one and the answer I found was at Junian.Dev.
The short version is, grab the default Hugo RSS template, save it
in layouts/_default/rss.xml and change the single reference of .Summary to
.Content.