Here is a tutorial for a custom Section Title
Say we have 3 Sections in our site:
/exhibitions/
, /artists/
and /art-fairs/
Hugo names Section list pages after the name of the directory, which is pretty straight forward.
But in this case we need the Art Fairs section to have a title of <title>Art Fairs</title>
and not <title>Art-fairs</title>
(that is the default way Hugo generates the title)
In your site’s <head>
type the following
<title>{{ if .IsHome }}{{ .Title }}
(if on homepage (index.html) the Title is defined from config.toml)
{{ else }}
{{ if .IsNode }}{{if eq .Section "art-fairs"}}Art Fairs · {{ .Site.Title }}{{end}}{{end}}
Here is the magic part.
First we use {{ if .IsNode }}
to define that the following will be rendered on the section list page only. Then with {{if eq .Section "art-fairs"}}
we tell Hugo the section in which we need the custom title Art Fairs · {{ .Site.Title }}{{end}}{{end}}
Of course now that we declared a custom title for the Art Fairs section we need to state the title for the other sections and pages. Here is the full snippet, it’s a bit of a mouthful but it does what it’s supposed to do:
<title>{{ if .IsHome }}{{ .Title }}{{ else }}{{ if .IsNode }}{{if eq .Section "art-fairs"}}Art Fairs · {{ .Site.Title }}{{end}}{{end}}{{ if .IsNode }}{{if eq .Section "artists"}}{{ .Title }} · {{ .Site.Title }}{{ end }}{{ end }}{{ if .IsNode }}{{if eq .Section "exhibitions"}}{{ .Title }} · {{ .Site.Title }}{{ end }}{{ end }}{{ if .IsPage }}{{ .Title }} · {{ .Site.Title }}{{ end }}{{ end }}</title>
And there you have it. If you think that you can improve on this be my guest. I tried several combinations and this is the one that works for me.