Add Pages Template
opened this issue · comments
Output pages using site.html_pages
to prevent txt
files from outputting and XML with embedded XSLT templates from attempting to be transformed.
I wasn't aware of that variable! I'm assuming that this would return pages, blog posts and other collection content from the Jekyll site? Or does it exclude posts and collection content? I haven't had a chance to test it and it's unclear to me from the documentation.
Thanks!
I'm working on a Prototype right now I'll drop you the template when I finish just don't let me forget!
Sounds good. Thanks! When it's done and the pull request goes through please consider submitting a similar change for my jekyll-json-feed project.
Bad news to share. When used on a medium complexity site Jekyll 3.3.1 causes liquid to spill into the feed. As a result I have nothing to share I would feel comfortable sharing. To reproduce the funky liquid not rendering behavior please see the following instructions: Phlow/feeling-responsive#151
Spent a few hours on it and, unfortunately, liquid output to the feed is a showstopper for me. Closing issue as a result. Please feel free to reopen for your own pursuits.
Got page feeds working wonderfully with jekyll-feed
by the way. If doing this be sure to scrub your output for sensitive files such as .well-known/acme-challenge/qXWXT3LE-/index.html
.
To clarify, you're saying Liquid spills into the feed when you use site.html_pages
instead of site.pages
or site.posts
? How odd! Must be an issue with Jekyll.
I haven't tried to recreate it but will take a look when I have time. Thanks for trying!
Seemed it was a Jekyll issue. Hard to say. It's an edge or corner case though, as it doesn't happen out of the box. In my case I was using Jekyll 3.3.1 and seeing unprocessed liquid output in my RSS page feed on a medium-sized site when looping over site.html_pages
.
In this case a medium-sized site means:
- About 10 pages made of files ending in both
html
andmd
- Liberal use of
_data
YAML within templates - About 25 includes to build pages and posts
- 4 meaty blog posts
- 5 collections with a combined total of ~230 items
- A good amount of blob data in
_uploads
I wasn't able to isolate the specific area where the edge or corner case was occurring. Here's the liquid I started to write to output the pages, but decided not to further enhance after switching to Atom when taking jekyll-feed
:
{% comment %}
When processing pages we use `site.html_pages` for security reasons.
Doing so prevents things like `letsencrypt.txt` from being output.
It also prevents liquid from transforming XML documents using XSLT.
Template also requires an explicit opt-in via use of `page.export`.
Use of opt-in helps guard against unintended output on some sites.
{% endcomment %}
{% for page in site.html_pages %}
{% if page.export %}
<item type="page">
<title>{{ page.title | xml_escape }}</title>
<description>{{ page.content | xml_escape }}</description>
{% if page.date %}
<pubDate>{{ page.date | date_to_rfc822 }}</pubDate>
{% endif %}
<link>{{ page.url | prepend: site.baseurl | prepend: site.url }}</link>
<guid isPermaLink="true">{{ page.url | prepend: site.baseurl | prepend: site.url }}</guid>
<dc:creator>{{ site.author | xml_escape }}</dc:creator>
{% for cat in page.categories %}
<category domain="category">{{ cat | xml_escape }}</category>
{% endfor %}
{% for tag in page.tags %}
<category domain="tag">{{ tag | xml_escape }}</category>
{% endfor %}
</item>
{% endif %}
{% endfor %}
Note the non-standard use of type
on the item
element. I'm sure there's a better way, but I never got that far. I'm using Dublin Core to define the author using dc:creator
and XML namespaces defined in the rss
element. Dublin Core also supports an element dc:type
for identifying items such as aggregations (Collections), and looked promising but, alas, fell short of expectations.