Get section title from

mysection is a folder inside content. The folder has an with following content:

title: "My Awesome Section"

In the code below

{{ $mysection := where .Pages "Section" "mysection" }}
<h1>My Awesome Section</h1>
{{ range $mysection }}
{{ end }}

How do I access the section title ("My Awesome Section") from to put inside h1 instead of hard-coding it?

If the template code you posted is in a list template, e.g. layouts/mysection/list.html then you can use {{ .Title }}.

If not, you may have to use {{ (site.GetPage "mysection").Title }} or something like that.


The code was in index.html. {{ .Title }} did not work but the other option did. Thanks!