Nested folders issue

I need to have my own folders, e.g. /projects/, /projects/proj1, /projects/proj1/details

I have these in my content folder:

image

But for some reason it is not showing the internal content, but just the title itself.

Am I missing something?

Probably. However since we can’t see what the rest of your site code looks like, it’s difficult for anyone else to say what exactly.

Please have a read about Requesting Help to see how to make it easier to get help here.

My apologies, I forgot to mention that I am using GitHub - formspree/blogophonic-hugo: Blogophonic – a Hugo blog theme by Formspree

After further trying it out, it seems like it is actually working correctly, and I am using it incorrectly.

Is it possible to add contents to _index.md’s body? Seems like it only reads the front matter…

Update:

I found out that it is using the _index.md correctly and is rendering as per layouts/_default/list.html , instead of via layouts/page/standard.html , hence the .Content is not being shown. Is it possible to get it to recognise it as a Page instead of a default List?

Rename

projects/proj1/_index.md

to:

projects/proj1/index.md

Read more about _index.md files here:
https://gohugo.io/content-management/organization/#index-pages-_indexmd

1 Like

Thanks, that is what I did, but if I did that, then my /projects and /projects/proj1/ does not show correctly (or even 404 for the nested pages if I used index.md instead). After looking a bit more seems like it is treating them as List type and not Page type, and I don’t know how to change that… I have updated my previous post

Please share a link to the public repository for your project.

Please try this branch Commits · CyberMew/blogophonic-hugo · GitHub. I also tried renaming to just index.md and it don’t work well GitHub - CyberMew/blogophonic-hugo at nestedpages-index

I’m not entirely sure I understand what you want to achieve.

What do you want to see when you navigate to

  • /projects/ ?
  • /projects/proj1/ ?
  • /projects/proj1/details/ ?

I want to see the content inside the md files

To render the content, the template must include {{ .Content }}.

Templates are either single page page templates (used to render foo.md or index.md) or list templates (used to render _index.md and top level sections).

The template selected is based on defined lookup order.

Simply specifying a different layout value in front matter will only work if the corresponding template can be found in the lookup order. This comment might help you understand how to specify a particular template.

Thank you, the comment is really very helpful in understanding with concrete examples.

In my case I wanted to have nested folders (sections/list?), hence I think I have to use the _index.md here for my folders (correct me if I am wrong).

Which means this is using list templates for my projects/ and projects/proj1 etc.

And from your linked comment it seems like option 3 is the best and cleanest way to go. I will create a folder/file in layouts/projects/list.html (seems like list and single is reserved names)

I have 2 questions…

  1. If we use pure html in /content/, the rules does not apply to it too right, since it is already raw html? Is front matter also required in this case?

  2. Any ideas what could have caused 404 in some cases? In my nestedpages-index branch, http://localhost:1313/projects/proj1 is giving 404.

The template lookup order is applicable regardless of content format (markdown, HTML, etc.).

The 404 error occurs because you are using an index.md file instead of an _index.md file.

content/projects/
├── proj1/
│   ├── details.md
│   └── index.md
└── index.md       <-- rename this to _index.md

Got it thanks a lot for your help! Would be nice if we can just use index.md there and it works though…