Can’t get both static home page AND pages in sub folders to work at the same time

Beating my head on this wall way too long. If I use content/_index.md my pages in subdirectories all work just fine, but the home page is a list of blog posts. If I use content/index.md my home page works but all other pages linked on the menu are 404.

I have tried changing the content of theme/hugo-casper-two/layouts/index.html but this does not seem to change anything.

My content structure is like this, mainly due to a couple of shortcuts I’m using:

Content/_index.md
Content/about/index.md
Content/about/images/(multiple jpegs)

Etc.

What am I doing wrong on this one?

Docs here: https://gohugo.io/content-management/page-bundles/

Using content/index.md means that Hugo interprets your page as a Leaf Bundle. This means that all other page-type content under it are treated as Page Resources, which in this case would have no Permalinks.

Ok, thanks. I think I understand that a bit better now, but how do I tell Hugo to stop using a list of blog posts for the home page? It is defaulting to that, even with no index.md in /content/, and I can’t find where the theme specifies it…

It’ll be in the homepage template, likely one of:

layouts/index.html
layouts/home.html

After severely modifying layouts/index.html, nothing changes. Is it using layouts/_default/list.html instead?

Site: https://dixonwildlifeart.com/
Code: https://github.com/dixonge/dwa-hugo

Hugo follows the following lookup rules: https://gohugo.io/templates/lookup-order/#examples-layout-lookup-for-home-page

The index.html in your theme is named Index.html, note the capital I. Hugo does not recognise this, so then moves down the list as per the layout lookup rules I linked to above, to find the next available layout file, and uses instead _default/list.html.

Rename Index.html to index.html with small letter i so Hugo recognises and uses that layout.

1 Like

So I am back where I started. Home page content with no other content, or home page as blog post list with all other sections working fine.

So how do I get a static home page with single layout and multiple nested leaf bundles underneath it?

  1. Use _index.md if you want child pages.
  2. Modify layouts/index.html to reflect what you want to be rendered in your homepage.

Yeah I am doing my editing in iOS Safari. Auto-caps is driving me crazy,

This is what I have been attempting since yesterday. Changes to that file do not seem to be recognized. Will try again…

So I renamed the file to _index.md and modified theme/themename/layouts/index.html by commenting out the post-list partial and inserting a {{ .Content }} section.

It worked! Fugly, but functional. It’s all cleanup and css from here.

THANK YOU! All of you, seriously…

Hi,

I’m trying to do something similar to this,

I want my pages to be like this:

gallery/tattoo-making/
gallery/tattoo-removal/
gallery/tattoo-training/

I created .md files like this:
Screenshot_1

and under theme/themename/layouts:
image

But when I open the page localhost:1313/gallery/tattoo-making/
only home page renders

What should I do to create multiple paths under one folder name?

I got the solution from this link:
https://discourse.gohugo.io/t/my-experiences-with-hugos-template-lookup-order/9959

Hi there,

I am closing this topic as this question has been marked as solved. If the solution here does not work for you, please open a new topic. Have a read about Requesting Help to see how to ask for help, and please note the section on showing us your code. Screenshots are not really helpful.

1 Like