Same posts in home page and category pages

I went from Hugo v0.42 to v0.101.0 for my blog and had quite a few things break in my theme, functionalities, etc. While I managed to fix many things, this is one of the things I still couldn’t do.

I get the same list of posts on my home page and my other category pages based on folders (programming, recipes, travel).

{{ $paginator := .Paginate (where .Site.Pages.ByDate.Reverse "Type" "in" (slice "post" "programming" "travelogue" "recipes")) }}
{{ range $paginator.Pages }}

I managed to round down the problem to these lines in the post-list.html file but all my experiments failed. I either get category pages with relevant posts and the home page just merely listing out the categories, or I get the home page and category pages listing out all posts and not having it separated / relevant.

Here’s the link to my blog: https://www.ankuroh.com/
The theme I had been using: https://github.com/eueung/hugo-casper-two

Can someone please help me here? Thanks!

First, themes/duck-hugo/layouts/_default/terms.html is never used. If you want a unique template for term pages, you need to rename this to themes/duck-hugo/layouts/_default/term.html.

Second, you are calling the same partial for all of your list pages:

{{ partial "post-list" . }}

And it always uses the same page collection.

It is doing what you are telling it to do.

Thanks for the response @jmooring!

Yes, I understand that it is doing what it has been asked to do. However, the line worked fine when I was operating in v0.42; so I am still struggling with how to go about the changes.

If this logic makes sense, I can think of having an if-else condition that says if it’s a home page, then display everything, else, display section/type specific posts. I managed to get the if part and the else part but separately. What would be the if-else condition to detect if the page is a home/landing page, could you please help me with this?

As for your other suggestion, I renamed it to term.html, although had no idea what this was doing. Just read about it from the documentation but still struggling with where else to call this file because you said it is not being used anywhere.

Thanks for the help so far nevertheless!

Evaluate .Kind in your conditional.

Thanks a lot @jmooring

For anyone else stumbling upon this page; the solution would be something like this:

{{ if eq .Kind "home" }}
.....whatever you want to do as per the home page......
{{ else }}
......something else you want to do on other pages.....
{{ end }}

Alternatively, you can also do it section-wise:
{{ if eq .Section "whatever-is-your-section" }}

Another way, both my index.html and list.html were calling post-list.html file.

You can also create a home-post-list.html file that caters to index.html whereas the post-list.html file caters to list.html (sections for example).

Reference to Page Kinds:
https://gohugo.io/templates/section-templates/#page-kinds

Other references:
https://discourse.gohugo.io/t/how-to-check-for-home-page/149/25?u=ansin218