HUGO

Directory Structure For Site Pages

Apologies for a newbie question, but I’m struggling with setting up a directory structure so that all my pages are not top level. I’ve read the docs, but when I put pages in a folder structure, Hugo does not generate them. If I move them back to the top level everything works as expected.

These pages are all simple single static web pages.

This works

content
    history
        _index.md
    join
        _index.md
    leaders
        _index.md

themes
    custom (theme name)
        layouts
            history
                list.html
            join
                list.html
            leaders
                list.html

This does not work

content
    about    
        history
    ...

themes
    custom
        layouts
            about
                history
            ...

However, when I try and nest the folders in content and layouts under an “about” folder, Hugo does not render the .HTML files, just an index.xml file.

Thank you in advance for helping me organize my website, greatly appreciated!!

Karl

This depends on various settings such as Page Bundles, markdown file names and Lookup Order.

Can you post a link to your repo to help you review it?

The repo is private. The above folders and files are exactly what is in the repo.

I’ve read the docs and tried, but as explained in the original post, the HMTL files are not compiled as expected.

Do you know of a real-world example that demonstrates my scenario?

@bep do you have any examples for what I’m trying to do? Thank you very much,

Karl

There is not enough information. Sorry I can’t help.

1 Like

You cannot nest layout files in the same way you can do with content files.

As pointed out above, you need to consider (and thoroughly read about) Hugo’s lookup order, and specify custom types or layouts in the frontmatter as necessary.

You also do not need to tag specific people to ask for help. We are all volunteers here, and people will help out when they know the answers and have the free time to do so.

I’ve read all the docs and must be missing something.

Do you know of any examples that nest the content files?

Maybe my nesting of layouts caused my failures.

Thank you very much,

Karl

Thank you for trying, greatly appreicatred.

I changed my project to not nest the layout folders, so all the folders in the layout are top-level, but when I build it I’m not getting the HTML files only XML files in the public about/history about/join and about/leaders folders.

I’ve searched for an example, but can’t find one. This seems like a very common scenario, creating folders to put content in so that all the content folders are not top-level to content.

Thinking of another example, a site that presents information for states and cities in that state. This would require a content/state name folder for each state, and then subfolders for cities.

I hope I’m making sense. I’ve reread the docs twice, but obviously not connecting the dots.

Any example would be greatly appreciated.

BTW: I do not use the posts feature, all pages on my site are content pages without the blog posts features.

I finally figured it out. It would greatly help if the docs had real-world examples for complex scenarios.

Thank you for your responses,

Karl

1 Like

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