-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Rendering content from custom collections in posts #6211
Comments
FYI. I tried capturing the rendered text and applying the I did add a hack to the
When the Liquid tags are expanded (on pages), there's nothing to replace. When the literal is injected (on posts), the replace cleans it up. This isn't a real solution, though. |
There may be an intersection of this "quirk" with another reported in #6209 |
Commented out the line, but no change. v3.4.3. I see the same behavior on GitHub Pages.
|
Note: I'm not a Ruby dev, and I think all I did was change the source. I added gibberish and jekyll ran as usual, so .... how does one rebuild the gem from source? Google keeps pointing me to "building" your site (aka. jekyll usage). |
source? by that do you mean the repo cloned from GitHub?
An average user need not know about this, So you're better off not breaking Jekyll unintentionally. |
I took some time to examine the collection values (from the default.html template), with the interesting bit being:
Everywhere except for posts, I get the rendered HTML. Even the For posts, however, Hope that helps. |
What do you mean by that? Is it assigning the
?? |
I have a collection where users can put 0 or more markdown files for the footer ( Those items are included in the In the case of a post, the For example, the blog list is an But, as soon as I view an actual post (eg. from the |
Interesting.. can you provide a link to the exact "template" that includes the code for the sidebar? I was not able to find it. |
Hey @groundh0g! I worked with you on a few PRs to plusjade/jekyll-bootstrap way back when 👋 I think this is a really cool idea and I see the use case you are going for. I see how this could make things easier for users who are new to Jekyll. Could you provide just a simple repository with a really basic "This works, this doesn't" example? I think it would help if we were all looking at the same code. |
Sure thing. Thanks! Starting a new job today, but will try to get a simple repro case posted on a branch and post a link here as soon as possible. |
Hi, @pathawks. Here's a simple example to reproduce the issue. Just clone locally, then Navigate between Home / About / Post to see that the includes expand just fine in pages, but not in posts. I believe it's because posts are implemented and rendered as collections themselves, but that's just wild speculation on my part. Thanks for taking a peek. |
@groundh0g can you configure GitHub Pages to build the dummy-repo above? That'd help (me) inspect without cloning locally.. Thanks.. |
Sure thing. Try this: https://groundh0g.github.io/jekyll-collection-render-issue/index.html |
Ah yes.. I see it now.. 😃 👍 |
Got a chance to look into this. I even tried accessing default collection docs hash (Posts) to rule out other factors:
|
Is there a work-around, or is this a wait until GitHub Pages refreshes after a fix thing? |
While not a great workaround, and I'm not terribly pleased with the solution, I thought I would document a hack that seems to meet my needs. Maybe this will help fill the gap for those who google to this issue, this comment. So, the terrible hack is to move the collection content to their own pages, segregated by folder. That way, markdown files (with YAML headers) in the same path are in the same "collection".
This means iterating over all the pages in the site whenever I want to zero in on one of my groupings. The It's not very elegant, but I get my precious collections again. |
I'm not sure I understand. Can you provide an example directory listing, or something? |
If I had a collection defined in a folder named To get to that markdown's content, I would have to write a |
Thinking out loud: Not all documents are rendered at the same time. If posts are rendered before collections, it would make sense for the content of collections documents to appear unrendered. |
Makes sense to me. Especially if |
Right. Not sure there's a great solution here. |
So, the options are likely these, then? (Just spitballing for the record.)
In any case, I assume that I'll need to devise another scheme for my scenario in the interim for GitHub Pages. Thanks for the help guys. I hope this thread leads to a verified root cause, and that it's something that's easier to fix than an overhaul of the render pipeline. |
|
I think I may have just run into this (or very similar) bug. I have a collection
---
---
{% include_relative setup.coffee %}
{% include_relative header.coffee %} Which works fine, other than the fact that the included files are not rendered in time for the include. If I inspect the files afterwards, both I also noticed that I couldn't use liquid tags withing a coffeescript file, if I rename
|
Guys, I have the same bug here, and it began with a markdown parser change. Have you changed parsers, @groundh0g ? The below works okay for me with the default parsers, but after changing to one called via a plugin, I get the same issue.
I get proper processing of everything (files, frontmatter) right up until panel.output, and then I get nada.
test-post-9.md contains...
Commenting the line from the renderer that @ashmaroli mentioned above had no effect. |
Nope. No change in parser from the default, @RNCTX. Also, no added plugins. |
Based on your post above I think the answer, considering I can reproduce the problem by changing markdown parsers (via plugin, and thus likely changing the order in which things are processed), I would bet on 2 or a variation thereof. My plugin-called (global) parser was converting content, which I just tried changing to output but it didn't have any effect. So I changed the default parser back to kramdown, and instead of using my third-party parser globally I called it via a pipe to the plugin like... {{ post.content | markdown-it }} in the template, and everything works fine other than output and content being the same, which is back to the other bug mentioned previously. In short, @ashmaroli 's linked fix is a fix that needs applied regardless, otherwise there is no way to get discrete data from {{output}} and {{content}}. Is it possible to call a second renderer as a standalone plugin? If so that would fix my issue, as I could pipe collection.content | to-my-plugin. |
Why can't Jekyll render a file as part of the include process? Isn't that the expected
behavior of include and include_relative: to trigger a render and then
include the result?
|
@MattSturgeon this is all specific to collections. There is a different level of template control with a collection, I don't think this affects default posts and pages or there would surely be more bug reports. This seems to arise from calling content into/out of a collection from a file not in the collection. In my case I have a single-page site template that calls a 'recent post' list to populate hidden divs in the index file at the site root. My links are show/hide actions on those divs. I call the content from the collection folder into the index file at the site root. There are two bugs at play here, as ashmaroli eluded to. One, the gem package as distributed renders content and output from a collection the same but the docs say that one should be processed and the other should be raw. Commenting out the line linked above fixes that. I'm using v3.1.6 so that bug goes back at least that far. Two, there is something in the order in which these files are processed that causes both output and content to return blank strings for collection page content under certain circumstances. I can trigger this bug by changing the global markdown parser to a third-party one in _config. Not sure about all of the circumstances that groundh0g has reproduced, but at least one other because he says he hasn't touched the default markdown parser. |
Sorry, didn't mean pages only, I was just saying that whenever you include anything you expect whatever you include to be rendered. I'll edit for clarity. If it's already been rendered by a previous render pass, fine, use the result of that. Otherwise it should be rendered as part of the include process. |
Yes, I suspect that's what we're getting to, that there is a problem in the order in which these processes happen related only to collections. There is no apparent difference in the rendering process from two startup logs of the bundled webserver for me, one with kramdown and one with Markdown-it via a plugin. Only difference is one has post text and the other one doesn't. |
After studying this for a bit, I don't think this is a bug except for maybe the document's Attempt at tl;dr
I guess mine is a more elaborate version of this comment by @pathawks, though I have to point out that Long versionIf you look at code for
If you write a generator plugin in module Test
class Generator < Jekyll::Generator
def generate(site)
p site.collections
end
end
end then examine the output. You can see that the order in collections is
These are my guesses about liquid rendering
As I established earlier, On the other hand, when pages get processed, You can sort of see this in action if you create another collection Apologies for the (possibly bordering on inarticulate) wall of text. There's quite a lot going on and I don't know how to make it more concise. By the way, I tested with @groundh0g's example site which uses the default Kramdown converter and doesn't have any coffeescript files so I don't know if they can cause this issue. |
@i-give-up, thanks for the follow up. Curious about one thing, though. How would rendering the If this is just a byproduct of collections, and there's no simple fix, what's the next step? Should we document the scenario(s) / pitfalls and add it to the user docs? |
Haven't tested but in that case
I don't think it's common to use collections this way i.e. as snippets to be included in a layout file. It seems to be something that include files are supposed to do. As such, in my opinion a more sensible (structurally correct?) approach is to modify certain aspects of layout/include files
|
would be wonderful if I could simply use a plugin to force a second render. ie. This issue is nearly two years old, has anything changed? |
Banging my head against a wall with this as well. Any update at all? |
I believe this is related: #6465 |
I'm guessing this isn't fixed and no workaround? Just spent my whole morning troubleshooting a bug that ended up being this |
And just like that, 4 years... |
Hello Everyone, this issue is still "unfixed" as of Jekyll 4.3. |
I believe this to be a bug, not a question about using Jekyll.
I updated to the latest Jekyll (or) if on GitHub Pages to the latest
github-pages
I ran
jekyll doctor
to check my configurationI read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/
I am on (or have tested on) macOS 10+
I had an error on GitHub Pages, and I have reproduced it locally.
My Reproduction Steps
This is not a build error, it's a rendering quirk. There are no logs to provide.
I'm extending Jekyll using only Liquid and JavaScript, so that things work on GitHub Pages (no plugins). This issue uses no JavaScript, though. I believe it's a rendering quirk in how Liquid is interpreted from within collections.
I have a collection for
_sidebars
and_footers
. They're pulled into the templates via{% include ... %}
tags that run Liquid to iterate over the collection files.{{ x }}
and{% x %}
tags are rendered literally (rather than expanded)._posts
collection, the behavior is the same.The Output I Wanted
I would love it if
{{ x }}
and{% x%}
tags were expanded when:_posts
)There is no log for this issue. It's a question surrounding the rendering of Liquid variables within nested collections. (In my use case, it's not obvious that the collections are nested, since
_posts
is implemented as a collection, itself.)/cc @jekyll/build
The text was updated successfully, but these errors were encountered: