I have a very odd occurrence to me that I’m trying to debug…
I am looping through every page in my site and dumping them all out on a single page so users can print
write out the contents with {{page_item.content}}
and if the file is called a.md it processes the {{}} variables, if the file is called q.md it doesn’t process the variables
{% for page_item in site.pages %}
{% if "/about/" == page_item.permalink %}
{{ page_item.permalink }}
{{ page_item.name }}
{{page_item.content}}
{% endif %}
{% endfor %}
If the file is named about.md, the page_item|jsonify includes the value of the site.baseurl variable.
But if I rename the file to q.md, the page_item|jsonify just includes the literal string {{site.baseurl}}
Here’s the first 8 lines of the md file:
---
layout: page
title: About
permalink: /about/
description: (About Page)
---
{{site.baseurl}}
# About
When run the script above on about.md, it prints out html "/data<h1>About</a>"
("/data" is the value of site.baseurl)
When I run the script above on the same file, but named q.md, it prints out html "{{site.baseurl}}<h1>About<h1>"
Oddly to me, the contents of the page written out to the _site folder’s about/index.html are proper.
Thanks, nice catch. I’ll edit my original post. That was me cutting and pasting poorly, there is an if there, the full code that is trying to print the page content is…
{% for page_item in site.pages %}
{% if "/about/" == page_item.permalink %}
{{ page_item.permalink }}
{{ page_item.name }}
{{page_item|jsonify}}
{% endif %}
{% endfor %}
what if you try other names for the file - does it only work if it is about.md? and fails if it is anything else? or does it randomly work?
why aren’t you using the .content part in your actual code? without that don’t you get all kinds of stuff? or are you just looking at the content part of that?
I think the item.content might not be fully processed? if there is markdown in it is it rendered as html or markdown? I wonder if the liquid is processed, I sort of remember something about that.
I’ve tried renaming the file to lots of different names. it works as a.md through p.md, q.md through z.md fails. I first found this out because stories.md didn’t work as expected.
I want to use page_item.content to render the page. I am using page_item|jsonify to look a the difference between files quickly since the json version of the content element will have the rendered variables for about.md, but have the template, raw strings for q.md.
There’s got to be some reason why the liquid isn’t processed for q.md files.
I have seen this before but don’t remember what exactly was the cause… I was trying to show the css of a site on a page in the site and it worked one way as unprocessed raw text and when I renamed the file to something else it was totally different as it was getting processed (?). I looked at that site to see if I left a note about why I thought that happened but I don’t see anything. It was something about the alphanumeric order of things I think.
basically you can do what you want, it just only works as you want it if the filename starts with a certain letter right? otherwise the liquid is not processed.
I tired to edit your post but I think it is still a bit off at the bottom. At the top I changed it to say if the file is called q.md it doesn’t process.. you had does.
AHA! I figured it out. The page where my loop was running was called “print.md” so I think any pages in site.pages after print.md weren’t rendered yet. I renamed print.md to zprint.md and now everything works.
ah - yes, I think that was the same thing I had - the filename I wanted my css to show on had to be after the css was rendered (or vice versa - can’t remember).
When I forget this solution in a few years, I hope this thread will show up through DDG and help future me
Thanks for being so responsive and helping me debug.