Skip to content

Making changes to templates with a child layout during --serve mode are not reflected in output (nunjucks layouts using inheritance) #4312

Description

@robole

Operating system

Ubuntu 24.04.4

Eleventy

3.1.6

Describe the bug

For projects that use Nunjucks as the template engine and use layouts that use Template Inheritance, changes are not reflected in the output during --serve mode. If you update a template (posts/post2.md) that uses the child layout (post.njk that extends base.njk), it does not write the changes to output. The log says that the file was written.

The initial build works fine. If you kill the server and rerun, the changes are reflected.

Upgrading to the lastest canary - v4.0.0-alpha.9 - removes this issue.

This may be the same issue as the layout invalidation issue #4310 that was fixed in v4.0.0-alpha.8.

If you rework the layouts to use the layout chaining method instead, it is not an issue.

Reproduce issue

I included a repo that reproduces the issue. To reproduce:

git clone https://github.com/robole/eleventy-template-update-issue
cd eleventy-template-update-issue
npm i
npx eleventy --serve
  1. Get the project set up locally as above.
  2. Open the post 2 page in the browser: http://localhost:8080/posts/post2/
  3. Open posts/post2.md, make a change, and save.

Expected result: http://localhost:8080/posts/post2/ is updated with your change.
Actual result: No change.

There is a branch called layout-chaining-working that works as expected. It has reworked the layouts using the chaining method instead.

Reproduction Source Code URL

https://github.com/robole/eleventy-template-update-issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions