Only one directory in /content is processed for the homepage?

I am having an issue where only one directory in the content directory is processed for the homepage.

To reproduce the problem you can create a new site by following Quick Start | Hugo but populate with some test content with

hugo new sub1/test1.md
hugo new sub2/test2.md

When I access the homepage at localhost:1313 only the test1 page is included - test2 is not included but localhost:1313/sub2/test2/ is generated.

It is only processing posts in the sub1 directory to display on the homepage.

What do I need to do to make the homepage include posts from all subdirectories in the content directory?

hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168+extended windows/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.19.2"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"

Thanks

Check each content file. Make sure that:

  1. Draft is not set to true
  2. The date si not in the future

If you need additional assistance, please post a link to the public repository for your project.

See https://discourse.gohugo.io/t/requesting-help/9132.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

I do not have a repository - it is create new site, get a theme, adjust archetype\default.md so draft: false, set theme line in config.toml and create two pages as explained on the Quick Start page.

Everything is basically created by Hugo but the dates seem fine to me test1 is fine, test2 created a few seconds later doesn’t appear.

Very strange there must be something I fundamentally do not understand or I can’t read which could be correct as I have tried everything over the past couple of days and I have got the problem simplified to this.

Thanks

Which is why we need to see your project. If you don’t have a repo, post a zip file somewhere. Please help us to help you.

OK, humour me.
Rename sub1 folder to sub3. Stop and start hugo server. What do you see?
:slight_smile:

So, as you should have found above, it is picking the FIRST section alphabetically.
It was a coincidence it was the one you created first.
Add this to your config.toml

[params]
  mainSections = ["sub1", "sub2", "sub3"]

And it should show any of the subsections named.
I went through the quickstart.

By default it is expecting content in a “post” folder, you can see that from the exampleSite provided with the theme.

Check out the homepage index.html layout for exactly how it is working in this theme.

{{/* Define a section to pull recent posts from. For Hugo 0.20 this will default to the section with the most number of pages. */}}

2 Likes

The alphabetical check also explains why during testing it seemed to change around but it was always just one directory that appeared the others were not processed - I just tried to simplify the problem and find a way to reproduce and explain it. The solution is as marked I needed to include mainSections in the config.toml. Much appreciated.

1 Like

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