How to exclude section dir to nested pages permalink?

Hi all,

Hope you’re good!

So, I have some nested pages in directory “pages”.

architecture example:

content 
|-- pages
|----- dir-1
|-------- subdir-1
|-------- subdir-2 
|----- dir-2

But I would like exclude this directory level for my build like:

/dir-1/
/dir-1/subdir-1/
/dir-1/subdir-2/
/dir-2/

I saw permalink but doesn’t work with nested pages.
The only one solution are to have path without this first level in url field?

example:

---
title: Subdir 1
url: /dir-1/subdir-1/
---

Thanks and happy new year,

Seb

Exclude from permalinks or builds?

If the former, see URL management

If the latter, see build options below

I expressed myself badly sorry,
not exclude but change url path and remove “/pages”
like https://www.mywebsite.com/dir-1/subdir-1/ and not https://www.mywebsite.com/pages/dir-1/subdir-1/

Then configuring permalinks should help you

Hi Steppa,

ok its working only with leaf page with this config:

[permalinks]
  pages = '/:sections[1:]/:slug/'

I created a repository for testing GitHub - sebousan/hugo-test: hugo-test,
you can see some pages in /content/ and see the result in /public/.

“My first page” is a branch page and is build in /public/pages/my-first-page/index.html not in /public/my-first-page/index.html

What do you think about this?

Thanks a lot.

OK, I found this comment of jmooring:
Permalinks defined in site configuration are not applicable to section pages / branch bundles”

In this issue:

So, url in frontmatter is the only way to set a different permalink for branch page

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.