HUGO

Identifying section/layout/aso. in baseof.html

Is it possible to know inside of baseof.html what section or layout or template we are in? In this specific case I want to add classes to the body-tag identifying the section, taxonomy, “whatever” we are in (eg. section-archive, section-posts, section-contact).

thanks
patrick

I just realize I could solve this with a block {{ block “section” . }}{{ end }} that is filled in the section template (if I have one for instance).

<body class="class1 class2 {{ block "section" . }}{{ end }}">

You cannot access “the template name” from the template itself. But there are lots of page variables that may be of help (Type, Section, Layout (if set) …, Kind etc.) that can be used to build CSS classes.

2 Likes