(wait, how'd I get the blog to do that?)
I specifically use a static blogging software written in a language I don’t know so I won’t be too tempted to spend all my time screwing with it instead of just getting things down. The typography needs some serious work. I have tweaked some things, though. So before I forget what everything in the hugo.toml does…
Including HTML
This was for embedding p5.js scripts and X3D files. I use the default markup renderer.
https://gohugo.io/getting-started/configuration-markup/
[markup.goldmark.renderer]
# Allows HTML in Markdown
unsafe = true # default is false
remapping “posts” to “excuses” on the QT
From about a year ago. (end of page.)
https://github.com/wowchemy/wowchemy-hugo-themes/issues/356
(note that pageRef gets used for internal pages now. url is only for external pages.)
[permalinks]
posts = "excuses/:title"
[menu]
[[menu.main]]
identifier = "posts"
name = "posts"
title = "posts"
pageRef = "/excuses/"
weight = 10
Code block formatting
theme = "etch"
enableInlineShortcodes = true
[markup]
[markup.highlight]
lineNos = false
codeFences = true
noClasses = false
Having a “storage” folder to put scrap files in
Didn’t document at the time but here ae some references:
- https://gohugo.io/hugo-modules/configuration/#module-config-mounts
- https://gohugo.io/hugo-modules/use-modules/
[module]
[[module.mounts]]
excludeFiles = '/posts/**/storage'
source = 'content'
target = 'content'
Using anchor tags
I forget. every. time.
- [link text A]({{< relref other-page-folder >}})
- [link text B]({{< relref “other-page-folder#header-id-text” >}})
- [link text C]({{< “#header-id-text” >}})
- adding a custom anchor?
{#usdcat}
at the end of a heading worked.
Adding the below to the toml means custom block attributes are also now possible.
[markup.goldmark.parser.attribute]
# Allows custom attributes
block = true # default is false
my fancy paragraph that I will want to link to again
{id="id-anchor-name-wanted-for-block"}
The above will slip that id attribute into the <p>
or other block tag, which then can be used as an anchor.
Adding a Series
I don’t love the way the layout currently happens, but it took 3 pretty simple steps:
- create the taxonomy
- create the partial / other templates
- add the partial to the default layout (this overrides the theme’s)
hugo.toml
Once a custom taxonomy gets added the default ones go away so tags
has to be there, too.
[taxonomies]
series = "series"
tag = "tags"
layouts > partials > series.html
{{ if .Params.series }}
<div>
<h4>This article is part of a series.</h4>
<ul class="list-group">
{{ range $num,$post := (index .Site.Taxonomies.series (index .Params.series 0 | urlize)).Pages.ByDate }}
{{ if eq $post.Permalink $.Page.Permalink }}
<li class="list-group-item active">
Part {{ add $num 1 }}: This Article
</li>
{{ else }}
<li class="list-group-item">
<a href="{{$post.Permalink}}">
Part {{ add $num 1 }}: {{ $post.Params.title}}
</a>
</li>
{{end}}
{{end}}
</ul>
</div>
{{end}}
layouts > _default > single.html
{{ define "main" }}
<article>
<header id="post-header">
<h1>{{ .Title }}</h1>
<div>
{{- if isset .Params "date" -}}
{{ if eq .Lastmod .Date }}
<time>{{ .Date | time.Format (i18n "post.created") }}</time>
{{ else }}
<time>{{ .Lastmod | time.Format (i18n "post.updated") }}</time>
{{ end }}
{{- end -}}
</div>
</header>
{{ partial "series.html" . }}
{{- .Content -}}
{{ partial "series.html" . }}
</article>
{{ end }}
Adding a tags page
- https://gohugo.io/templates/taxonomy-templates/#order-alphabetically-example
- https://discourse.gohugo.io/t/tag-cloud/6335
- https://discourse.gohugo.io/t/taxonomy-list-template-pages-vs-data-terms/45919
- https://gohugo.io/templates/data-templates/
- https://gohugo.io/templates/taxonomy-templates/
In addition to having it listed in the taxonomies section of the toml…
[[menu.main]]
name = "tags"
identifier = "tags"
title = "tags"
pageRef = "/tags"
weight = 20
layouts/tags/list.html
combination of a tag cloud example and an example on how to list things alphabetically from the hugo website.
{{ define "main" }}
<h3>{{ .Title }}</h3>
<div id="theme-tagcloud" class="col-sm-12" style="margin-top: 15px;">
{{ range .Data.Terms.ByCount }}
<a href="{{ .Page.Permalink }}" class="btn btn-default" role="button" style="padding-right: 5px; padding-left: 5px;" >{{ .Page.Title }} <!--<span class="badge">({{ .Count }})</span>--></a>
{{ end }}
</div>
{{ end }}
layouts/tags/term.html
copy of the taxonomy.html from the etch theme.
{{ define "main" }}
<h3>{{ .Title }}</h3>
<ul id="posts">
{{- range .Pages }}
{{ .Render "li" }}
{{- end }}
</ul>
{{ end }}