Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to front matter data are not hot-reloaded in collections #3505

Open
sebthom opened this issue Oct 24, 2024 · 2 comments
Open

Changes to front matter data are not hot-reloaded in collections #3505

sebthom opened this issue Oct 24, 2024 · 2 comments

Comments

@sebthom
Copy link

sebthom commented Oct 24, 2024

Operating system

Windows 10

Eleventy

3.0.0

Describe the bug

I'm trying to render an index page for blog posts where I access front matter data stored in each markdown blog post file.
While running the dev server I can see that changes to the front matter data trigger a reload of pages in the browser but the objects returned in collections don't contain updated values. So I need to restart the dev server after each change.

When rendering a single blog post page, hot reload works for changes to the blog post's content or front matter data.

So the issue seems to be related to some kind of collection caching.

Reproduction steps

  1. Create a blog post with front matter data, e.g.

    ---
    author: John Doe
    title: Hello World
    tags: demo
    ---
    This is a blog post!
  2. Create a index page

    <ul>
      {% for post in collections.demo %}
          <li>
            <a href="{{ post.url }}">{{ post.title }}</a>
            <p>{{ post.author }}</p>
          </li>
      {% endfor %}
    </ul>
  3. Start the dev server: npx @11ty/eleventy --serve --quiet --incremental

  4. Open the index page in the browser

  5. Change+save the blog posts front matter data.

  6. The index page will be reloaded in the browser but the old data will be displayed

Expected behavior

No response

Reproduction URL

No response

Screenshots

No response

@Wu-Lipeng
Copy link

This might be caused by browser caching. Clearing the browser cache may work.

@Wu-Lipeng
Copy link

Another possibility : Eleventy may not correctly detect changes to certain data, especially when the front matter is modified, causing the browser to display outdated content. You might want to disable incremental builds and force Eleventy to perform a full rebuild, ensuring that the latest content is loaded after each change. For example, you can explicitly disable incremental builds in the eleventy.js configuration file like this:

module.exports = function(eleventyConfig) { 
eleventyConfig.setIncrementalBuild(false); // 禁用增量构建
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@sebthom @Wu-Lipeng and others