How to use different partials based on directory path?

Currently I am using single header across all pages. But I would like to add header_2 on all pages that starts with /blog and all of the child post under /blog, is that possible?

I’ve tried using:

{{ if path.Dir "/blog" }}
  {{ partial "header" . }}
{{ end }}

But it won’t work.

I’ve considered creating different baseof.html layouts but I think that’s kinda dirty as I only need to change the header.

Any advices are greatly appreciated, thank you!

Try:

{{ if eq .Section “blog” }}
{{ partial “header” . }}
{{ end }}

@bep
I didn’t figure out that’s called as section. That’s very helpful, thank you! :grinning: