Problem with layout markdown field in 0.146+

I have the following structure:

/content/
  /blog/
    index.md
    /2024/
    /2025/
      /2025-01-01-blog-post/
        index.md

In /content/blog/index.md I set a custom layout file with layout in the frontmatter:

---
title: "Blog"
layout: "index"
---

I have a custom theme with the following structure:

/themes/
  /my-theme/
    /layouts/
      /blog/
        index.html
        single.html
        list.html

After upgrading to 0.146.1, it stopped using index.html and is using list.html instead. Is this a bug, or am I doing something wrong here?

I managed to solve the issue by renaming index.html to root.html and then updating the layout field in frontmatter:

---
title: "Blog"
layout: "root"
---

I don’t quite understand why it works, though. Is this a bug, or am I missing something here?

I’m not sure. What you see is probably a symptom of us trying to be compatible with the old setup, but it looks odd. I’ll have a look:

1 Like

I happened to notice that the issue you created has been closed. There is a comment by @jmooring saying my layout directory structure is unexpected.

I have two questions, but before I ask them, I will explain what I tried to achieve with this template structure (which worked fine before the update).

I want to have a separate landing page for a blog (example.com/blog) that looks different than a single post (example.com/2025/my-post/) or a yearly archive list (https://example.com/2025/). The root of the blog is not just a simple list view. That is why I have three different templates, and that is also why index.md contains a separate layout definition in the front matter.

So, my questions are:

  1. Why does this work when the layout is called root but not when it is called index? Based on the documentation, the layout field in the front matter “provide a template name to target a specific template, overriding the default template lookup order.”
  2. What would be the less unexpected or the correct way to achieve the same end result?

The template’s base file name should be anything but index.

1 Like

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