[Solved] Conditionnal Templating with GetPage

Hello,

To avoid the multiplication of specific template, I would like to condition the display according to its section.

{{ with .Site.GetPage "section" "news" }}
some kind of template
{{ end }}


{{ with .Site.GetPage "section" "event" }}
some kind of template
{{ end }}


{{ with .Site.GetPage "section" "blog" }}
some kind of template
{{ end }}

Unfortunately for the /news /event and /blog pages the 3 displays are present

What would be the right method ?

Thank you for your help.

Assuming that you want to use the current page’s section, you would use the .Section page variable.

{{ if eq .Section "news" }}
1 Like

Thanks @moorereason ,
I will try it !