Is it possible to have a homepage not using _index.md?

Hey there!
I try to create a modular homepage. This means I want to have my content split into multiple .md files. This is possible by using a leaf bundle.

However this does not seem to work for the home page, since all sub pages would be treated as page resource. I also tried to move the root page into /home and set slug: '/'. This is working so far, however IsHome returns true in that case.

I have the feeling, that the homepage can only be placed inside a _index.md file or by directly using the theme index.html template. But that would mean modular pages (e.g. implemented via leaf bundles) is not possible at all with hugo (0.80). Is that correct?

No. It is not correct.

The _index.md is an optional file for list pages -including the homepage- meant for adding metadata, content etc.

By default the template that controls the homepage would be /layouts/index.html or /layouts/_default/index.html

However you can do whatever you need.

For example by setting the url front matter parameter of an index.md (leaf page bundle) to the baseURL value would effectively turn that page into the homepage. Also this leaf bundle can be ruled by whatever template you wish via setting the layout front matter parameter.

Yes, it is possible to have a modular -as you put it- homepage with its own page resources and custom template, without having to turn the entire contentDir into the leaf bundle of the homepage.

1 Like

I see, but setting url in the frontmatter still does not give me IsHome set to true. I expected that hugo would have a feature like specifying the homedir in config.toml. That would make most sense I guess.

I’ve seen your email about kind = home, but you have deleted the post. It also does not seem to work, is it a bug?

No. It is not a bug. kind cannot be set manually. (I remembered afterwards).

But above you mentioned that if you use a directory called /home/ as a leaf bundle then in this case .IsHome returns true. Is that so? (currently I’ve no time for testing myself).

No, it sadly does not return true, but I need it to do so.

Have content/_index.md as your main homepage content, then

content
├── home
│   ├── _index.md
│   ├── one.md
│   ├── two.md
│   └── three.md

Where home/_index.md is a headless collection: Build Options | Hugo

Then in your layouts/index.html

{{ $home := site.GetPage "home" }}

{{ range $home.Pages }}
etc
1 Like