Slug for leaf/index pages

Dear community,

slug does not seam to work for leaf pages. This is my setup:

content/
├── contact
│   ├── index.md
│   ├── index.fr.md
│   ├── index.de.md

index.de.md contains this front matter:

+++
slug = "kontakt"
+++

Yet, this page is rendered: /de/contact/kontakt/index.html (wanted: /de/kontakt/index.html).

page = "/:slug/"

does not change the URL.

Background:

  • I would like to avoid translationKey. This can get tricky.
  • It would be great to have all related content in one folder—including page resources. Therefore I am trying to avoid e. g. contact.md and contact.de.md in the root folder.

Thanks!

I have:

content/
   page/
      about/
         index.en.md
         index.ja.md

… and:

[permalinks]
    post = "/:section/:slug"
    page = "/:slug"

With the latest hugo, it’s working for me. Did you try:

 contact = "/:slug/"
1 Like

Thank you!

That’s a very clever hack.

It also allows (simulating) deep nesting/subfolders of leaf pages—a feature I always missed(*). The only disadvantage maybe is that you need to slugify all leaf pages.

Yes, I had tried contact = "/:slug/", but it did not work—and the site is far too big for this.

(*) My hack for deep nesting was using _index.md files in subfolders with front matter layout = "single". Your hack is a lot more out of the box!