Jekyll version 2.5.3
We are trying to write a plugin to promote content that is agnostic as to whether or not its a page or a post. However there is some difference between pages and posts that is not clear.
# this does not work
site.pages.each do |page|
# this does not show up in liquid
page.data['baz'] = 'Foo'
end
# this does work
site.posts.each do |post|
# this does show up in liquid
post.data['baz'] = 'Bar'
end
Any ideas as to why mutating the .data
hash for posts is accessible in liquid, but mutating the .data
hash for pages has no effect?
We've also tested this with .data["title"]
and it has an effect on posts
but page
titles are uneffected.
{% for post in site.posts %}
<div class="postbaz">{{ post.baz }}</div>
{% endfor %}
{% for page in site.pages %}
<div class="pagebaz">{{ page.baz }}</div>
{% endfor %}
yields
<div class="postbaz">Foo</div>
<div class="postbaz">Foo</div>
<div class="postbaz">Foo</div>
<div class="pagebaz"></div>
<div class="pagebaz"></div>
page
. In my reproduction code it waspages
, good catch; I moved it back topage
and have the same problem. – Fresheyeball