How to disable section but child are accessible?

Hi guys,
I have this structure:


and I set permalinks in config:

  menu = "/:filename"

What is the best way to set /menu list as not existing (404) but /page1/ and /page2/are accessible?

I know I can put and in the root of content/ folder, but is a way how can I do the same if pages are in menu folder?

If I create empty file /layout/menu/list.html it shows nothing for /menu/ but ideally I would like to get 404 error.

both can help

Thanks for links, I already read this pages, but I am still confused how to achieve this. I tried to add and with headless=true or without. I still get list of pages for url http://localhost:1313/menu/

  • rename menu/list.html template to empty.html
  • put anything in the content to check the right template is used


  • set layout=“empty”
  • set headless=true in frontmatter

use hugo --debug to get more information

if I set headless then all children are 404 not found…

only for !

@Marek_Lichtner You could redirect the user to your 404 page. So in your layout/menu/list.html have something like this

<!DOCTYPE html>
    <meta http-equiv="refresh" content="0; url=/404/" />

Hi guys!

I’ve just found a solution that works for me. This is the content of

url = "/"

The advantage is that the url to this branch is not displayed in sitemap.xml(!).

However, I don’t know if this solution will work permanently because the same URL is used for multiple pages. A headless option for branches ( would be safer.

This question is related.