Skip to content

:slugorcontentbasename creates subdirectory for section page #14104

@dvdksn

Description

@dvdksn

I've been using the slugorfilename permalink token to strip out the first section, like so:

permalinks:
  page:
    foo: /:sections[1:]/:slugorfilename/
  section:
    foo: /:sections[1:]/:slugorfilename/

After getting warnings that this is deprecated, and I should use slugorcontentbasename instead, I tried it. But this seems to generate an additional subdirectory for section pages where the slugorfilename did not:

permalinks:
  page:
    foo: /:sections[1:]/:slugorcontentbasename/
  section:
    foo: /:sections[1:]/:slugorcontentbasename/

I.e., given content pages like this:

$ tree content/
content/
└── foo
    ├── _index.md
    └── bar
        ├── _index.md
        └── somepage.md

3 directories, 3 files

The html output for content/bar/_index.md is generated at public/bar/bar/html:

$ tree public/
public/
├── bar
│   ├── bar
│   │   └── index.html
│   └── somepage
│       └── index.html
└── foo
    └── index.html

5 directories, 3 files

See repro: https://github.com/dvdksn/contentbasename

What version of Hugo are you using (hugo version)?

$ hugo version
v0.152.2

Does this issue reproduce with the latest release?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions