Iβve read the discussion about extending support for section frontmatter.
However, until that happens what is the recommendation on setting the <head><title></title> and <meta name="description"> for a section layouts/section/mysection.html?
Do I add some extra logic-fu to my layouts/partials/header.html?
Just for testing I tried setting {{.Section}} in my header.html, but it is always empty even when I visit a section, e.g. http://example.com/mysection/ where mysection exists in /layouts/sections/mysection.html.
@bep using {{if eq .URL "/mysection/"}}{{.Site.Data.section.mysection.title}}{{end}} worked great.
I have two further questions Iβve been thinking about which relates to what weβve discussed so far.
Is using a section a better way to create new βpagesβ akin to homepage, e.g. /about/ than to use a content file and layout, so
using a section /layouts/section/about.html /data/section/about.toml <-- for custom title and meta description
using a combination of content and layout /content/about.md /layouts/about/single.html
For the data file I canβt decide whether to use a single file for all sections, e.g. /data/sections.toml or a unique file for each section, e.g. /data/section/mysection.toml
/data/sections.toml
[about]
title = "About Me"
description = "Lots of juicy details"
[mysection]
title = "My Section"
description = "My section description"
/data/section/about.toml
title = "About Me"
description = "Lots of juicy details"
/data/section/mysection.toml
title = "My Section"
description = "My section description"
I know none of this really matters as the output is the same, but Iβd appreciate your thoughts nonetheless
On the first question about simple one-off pages, I usually create /content/about.md and set type = "about" in the front-matter. That will instruct Hugo to use the /layouts/about/single.html template.
Yeah thatβs what Iβve done as well. I just started to think more about this as I was working on a βtrueβ section and @bep suggested using a data file to solve my issue of setting a specific title and meta description for that section.
My reasoning for possibly changing my one-off pages from the way you describe to a section without a content file is that the single.html is meant for rendering a page within in a section. The idea being youβd usually have more than one page.
In this case weβre only talking about one page thatβs βstandaloneβ and so making it a section/about.html would perhaps fit better with the βhugo wayβ. Just my thoughts.
Btw my one-off pages content files tend to only have a few lines of frontmatter and zero content as the content is rather complex and I keep it in the single.html layout file.
Sorry to revive an old thread, but @mrsmith did you decide on an optimal way to set up section titles and descriptions? I am working on the same thing now, for a site with a lot of sections, so was hoping to benefit from your experience.
(As an example, this is about 1/10th of the current site - every section would need a title, 2-3 paragraphs of explanatory text and to list the pages it contains:)