List page inconsistently only renders one blank item

I have a personal blog that I maintain, and I upgraded the version of hugo that I use from 0.111.3 to 0.121.1. My blog uses a modified version of the archie theme, with the most notable modification being that the index.html acts similar to how a list.html page would, displaying all posts without pagination.

I’ve noticed, however, that inconsistently, my homepage will generate with a single post that has an empty title, like so

<ul class="posts">
        <li class="post">
                <a href="/"></a> <span class="meta">(Dec 28, 2023)</span>

in contrast to a normal set of list entries, like so

<ul class="posts"><li class="post">
                <a href="/posts/trackball-scroll/">Scrolling With Your Trackball in 2023 and <code>libinput</code></a> <span class="meta">(Dec 28, 2023)</span>

This seems to happen maybe every one in five builds, and I’m really not sure why. I have been trying to track down what’s going on here to file a bug, but I haven’t been able to figure out what’s wrong enough to provide a MWE.

Might someone be able to help me out here? Thanks!

Feh, I forgot to include a link to the full repo, and I can’t edit the original post for some reason. Here’s a link

I am unable to reproduce the problem as described, and I built the site 100 times with:

rm -rf public && hugo && grep "href=\"/\"" public/index.html

However, running hugo --printPathWarnings emits:

WARN  Duplicate target paths: /index.html (2), /index.xml (2)

So, when I’m building the site the same one always wins, but in your environment the result is inconsistent.

The problem is caused by the url front matter parameter in:

Side note… a baseURL without a protocol (e.g., // isn’t great for RSS and sitemaps.

Woah, that’s interesting. I totally missed that note in the FAQ. Thanks!

I guess my follow-up would be: how can I still preserve the posts list section as my homepage? I had originally done that url: / to achieve this effect, but I’m not sure if there’s a better way.

I originally got that idea from this post, I think How to set Section page as Homepage - #3 by zchenmtl

It looks like you edited the theme’s index.html file instead of overriding it, so edit themes/archie/layouts/index.html

Change this:

{{- range .Data.Pages -}}

To this:

{{- range where .Site.RegularPages "Section" "posts" -}}


TIL about where! Thank you so much.

1 Like

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