Homepage _index.org peculiar behavior

here is a sample of my file structure:

├── _index.org
├── ibrarys/
│   ├── books/
│   │   ├── buddha-stories/
│   │   │   └── index.org
│   │   └── _index.org
│   ├── _index.org
└── iwrters/
    ├── angelkate/
    │   ├── artichokle/
    │   │   └── index.org
    │   ├── _index.org

the _index.org homepage file just under content is pulling all the articles from the iwrters/author/article/index.org
eg the artichokle/index.org
(this behavior is undesirable for my purposes)

it is not pulling the buddha-stories/index.org though for some reason or anything i add to ibraries.
it is pulling anything i add to iwrters though.

the pulling everything from iwrters started when i (thanks to the helpful instruction of @jmooring ), changed all directories to lowercase. (i had some more serious issues when i had caps and some things weren’t working.)

in fact, if i change iwrters to Iwrters, the behavior stops and nothing is pulled on the homepage (which is desirable).

i would like to understand what is happening here:

  1. why capitalizing the toplevel directory to Iwrters stops the pulling behavior for iwrters
  2. why when i hugo new into the ibrarys/books/ directory, the homepage doesn’t pull what i’ve just added.

i am using the zen theme (slightly customized) and the list.html has:

{{ define "main" -}}
<main class="main layout__main">
    <h1 class="title">{{ .Title }}</h1>
    <i>{{ .Content }}</i>

    {{ $paginator := .Paginate (.Pages.ByTitle) -}}
    {{ range ($paginator.Pages) -}}
    {{ .Render "summary"}}
    {{ end -}}

    {{ partial "pagination.html" . }}
{{ end }}

You need to supply the project repo or a repo with dummy content that reproduces the issue for us to see the full context of the project i.e. configuration, templates etc.

Also see: Requesting Help

thx @onedrawingperday !!

here is the repo:

the items in ibrarys show up on the homepage while the item in iabbers doesn’t.

ibrarys was created first and i’m finding that may have something to do with it.

let me know if you require anything else.

When we ask for a sample repo it is best that it is setup so that the issue can be reproduced straight away.

In the link that you shared, all content files, including the homepage _index.md were drafts, also you had omitted the theme setting from the project’s config.

After fixing the above I saw that in the homepage template there is the following statement:

{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}

You have not specified any mainSections in the config, therefore the Section with the most content files is picked up to populate the homepage list, in this case the ibrarys Section.

What do you want to display on your homepage?

Also have a look at the following page in the documentation:

1 Like

thank you for your guidance!
i have been using hugo server -D -t prazen continuously and completely forgot that is an inconvenience for others. i have changed things in the repo.

i understand what the problem was thx to your instruction and after reading the text regarding mainSections.

i can stop the pulling of section files by putting the following in my config.toml:

mainSections = []

mainSections can be the above or [‘home’] or [‘anything-other-than-an-actual-section’]

i will follow-up on your where link further now that i have a much better idea of what to do.


Actually it is not a good idea to use empty parameters.

I suggest that instead that instead you remove the mainSections statement from the homepage template and instead filter the pages by the Section that you want to display by using where.

ok thx for that tip!

so playing around with this i found

{{ $pages := where .Site.RegularPages "Section" "iabbers"  }}

lists the items in iabbers

{{ $pages := where .Site.RegularPages "Section" "ibrarys"  }}

lists the items in ibrarys


{{ $pages := where .Site.RegularPages "Section" ""  }}
{{ $pages := where .Site.RegularPages "" ""  }}

gives nothing which is the desired behavior (for now).

however, is it bad practice to have blanks as arguments for the KEY and MATCH?
or is this the best way not to have anything pulled into the homepage?

If the desired behavior is not to have any regular pages on the homepage then simply delete the entire code block for the Page Collection as well as the Pagination.

It’s not a good idea to include empty conditions because you introduce ambiguity in your project and you might encounter unexpected behavior further down the line.

1 Like

ok that makes a lot of sense!
one may pay for taking the quick solution.

i’ve done things as per your suggestion and all is well!

thank you very much for the education @alexandros !

1 Like

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