Jekyll's Incremental Regen
Jekyll automatically regenerates all changed files into
a target directory _site
. However it does not regenerate
a file referencing another file which has just changed.
It has been particularly painful for index.html
file where
I reference a list of posts in a following loop:
{% for post in site.posts %}
<li>
<span class="post-meta">
{{ post.date | date: "%b %-d, %Y" }}
({{ post.language | capitalize }})
</span>
<h2>
{% assign is_draft = (post.path | truncate: 6, "") %}
{% if is_draft == "_draft" %} {% assign class_post_link = "post-link-draft" %}
{% else %} {% assign class_post_link = "post-link" %}
{% endif %}
<a class="{{ class_post_link }}"
href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
</li>
{% endfor %}
Now, I keep a list of files in _drafts
folder, they have no date specified,
neither as a part of the filename nor in the YAML front matter. Jekyll updates
their filenames with the current date when their content changes. But then
it does not regenerate index.html
. So far I forced the regeneration by
touch index.html
file, but did not seem to be neat solution I was searching for.
Much better approach is to add regenerate: true
to my index.html
YAML front matter. It forces the file to be included in each rebuild.
And it happens automatically.
I found it described at Jekyll’s GitHub Project, as a merge of Incremental Regeneration, and it is also referenced at the original Jekyll’s Documentation.