Single, latest post on home page

Is there a setting to restrict the home page to showing just the latest post or is that theme dependent?

If it’s theme dependent, what themes do this?

If you use a theme that does pagination, you can override the number of posts per page using your config.json. I believe the property is just paginate based on the Hugo docs.

Thanks for the answer. I’m using Kiko which I don’t believe has pagination. But I looked at the Hugo docs anyway and, not being a coder, realised that I’m in way too deep.

If you’re okay with just visually hiding the posts, you could use Custom CSS to accomplish this.

Navigate to DesignEdit CSS. Paste the snippet below and hit Update CSS.

/* Show all posts when pagination is present, but only the first one when not. */
.container:not(:has(#post-nav)) .list-item:nth-child(n + 2) {
  display: none;
}

The CSS above is tailored toward Kiko and your blog’s current settings. It might break if you change the theme in the future. Also, it uses the modern :has selector and won’t work in older web browsers.

Kiko will use pagination if you click that option on the Design page.

Then you can Edit Custom Theme, selection “config.json” and enter the following:

{
  "paginate": 1
}

That would set your pagination option to 1 post per page. Your home page would have just one page, and each click back on pagination would move you back one post.

I’ve done this, but it doesn’t appear to work.

The Kiko theme does not respect the paginate setting, unfortunately. Until it gets fixed, you could try the following config.json. It should work now and in the future after the theme gets updated.

{
  "paginate": 1,
  "params": {
    "archive-paginate": 1
  }
}

I’ve made a pull request with a fix that hopefully will get merged by @manton.

1 Like

Beat me to it. I was about to check this when I saw the email this morning.

1 Like

The pull request has been merged in, so this should show up as a plug-in update to Kiko shortly, if it’s not there already. Thanks y’all!

1 Like

Thanks everyone.

I’m singularly impressed how a small issue was quickly and efficiently resolved. It’s great that Micro.blog has this artisan baker vibe.

1 Like