How to retrieve parent folder name in Page Bundles

Hi there,

I’m now organising my content using the new Page Bundles.

I used to include a class in my element from the base filename e.g.

<article class="{{ .File.BaseFileName }}">

Which was handy for my css targeting because in the past I could apply styles to something like:


Now I’m using bundles I get


For everything, which is expected because my leaf content is organised like:


What I want is to recreate class="contact" in the new Page bundle content organisation approach.

I tried:

<article class="{{ .RelPermalink }}">

But I get:


I tried:

<article class="{{ .Dir }}">

But I get:


Is there a simple variable I’m forgetting that will give me the result I’m after, or do I need to add some kind of filter to remove the slashes?

If it’s the latter, would love some advice on how to do that. I’m not a regex guru.

Thanks much!

1 Like

Have not tried it in your scenario but, did you try {{ .Page.Slug }} or {{ .Slug }}?

Just gave that a try but they didn’t work.
Appreciate the help tho!


 {{ replace .Dir "/" "" }}



Well that was quick and easy!
I wasn’t sure if there was a variable natively available that didn’t require an extra function but that is definitely pretty clean.
Thanks much!

1 Like