404 a index under a folder in /content

I have a folder in /content called legal (primarily for file organisation). I don’t want /legal to exist but /terms should. Hopefully directory structure explains things.

└── content/
    └── legal/ *This should 404*
        ├── privacy.md (/privacy)
        ├── terms.md (/terms)
        └── cookies.md (/cookies)

Many thanks in advance.

Do redirect for /legal/ for example, if on Netlify, use _redirects in static folder

That will get rid off folder link

Set URL for each file in front matter to whatever you intend.

Shall work.

Thanks @idarek

I’ve got the urls set in the front matter url: /cookies is there no way to handle this on Hugo’s side instead of the redirect?

Test to use build option.

1 Like

Try adding the build options to the section’s _index.md file with everything set to false (except publishResources)

1 Like
---
cascade:
  _build:
    render: always
    list: always

_build:
  render: never
  list: never
---

Then use aliases with each page

From: hugo - Subpages without _index.md file - Stack Overflow

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