Check which page layout

Hi,

I can’t seem to find the solution but is there a way to check which page layout is being used, for example if you want to include/exclude something on specific page(s)?

Bump!

Hi, you might want to to something like this:

{{ if eq .Layout "nameOfYourTemplate" }}
   <div>some stuff to be shown if [nameOfYourTemplate] is used to render the current page</div>
{{ end }}

Seems to be missing from https://gohugo.io/variables/page/ even though .Kind and .Type are mentioned there.

I’m using this quite often, currently with Hugo 0.58.

Yea it’s weird it’s not the Page Variable list, but it is mentioned in the predefined front matter variables.

There’s also templates.Exists to allow you to make logic choices depending on if a template is found.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.