Page slug variable not being set

Heyo, pretty new to Jekyll, just picking through everything trying stuff out. Coming from a Wordpress background, but currently loving the flexibility and simplicity here.

That said, running into an issue with the page.slug variable. The variables documentation (Variables | Jekyll • Simple, blog-aware, static sites) seems to imply that page.slug is a variable that is available to all pages, which makes sense considering it’s stated to just be the filename sans extension. That said, it’s not being set in my fairly vanilla install (4.3.4) unless I explicitly set it in the frontmatter. I’m not using any theme, and I don’t have anything fancy going on outside of a tiny bit of defaults set for posts, and a single collection setup.

Curious to know if this is something amiss in the docs, something I’m misunderstanding, or a known bug?

Thanks :slight_smile:

Discovered it works just fine for posts, just not pages. Which seems a bit odd given it’s a value stored in the page object.

Is that expected behaviour?

how are you using it? I think it should work for pages but can’t say I have used it.

Using it in my top level layout to set a class on the body element.

<body class=“{{ page.slug }}”>

Do you have some default front matter set for pages in your _config.yml perhaps?