Skip to content
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

Liquid code being displayed in related-posts.html #1596

Closed
1 task done
steveng57 opened this issue Mar 7, 2024 · 7 comments
Closed
1 task done

Liquid code being displayed in related-posts.html #1596

steveng57 opened this issue Mar 7, 2024 · 7 comments
Labels
invalid This doesn't seem right

Comments

@steveng57
Copy link

steveng57 commented Mar 7, 2024

Checklist

How did you create the site?

Generated from chirpy-starter

Describe the bug

In my post markdown, if I have any liquid code immediately after the Front Matter, when this post is displayed in the "Further Reading" section (which I believe is defined by related-posts.html), then the liquid code is being displayed, instead of it being stripped out.

Steps To Reproduce

In related-posts.html the code to display a post is below, from line 85 or so. There doesn't look to be anything to strip out Liquid code.

                  {% include no-linenos.html content=post.content %}
                  {{ content | markdownify | strip_html | truncate: 200 | escape }}

Expected Behavior

I'm not a Jekyll expert by any means, but it looks like the code should be...

                  {% capture new-content %}
                    {% include no-linenos.html content=post.content %}
                  {% endcapture %}
                  {{ new-content | markdownify | strip_html | truncate: 200 | escape }}

Environment

  • Ruby: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x64-mingw-ucrt]
  • Jekyll: jekyll 4.3.3
  • Chirpy: jekyll-theme-chirpy (6.5.3)

Anything else?

No response

@steveng57
Copy link
Author

steveng57 commented Mar 7, 2024

Another, perhaps better solution, is to look for a 'description' field in the post Front Matter. If it does not exist, carry on as usual, if it does exist however, use it in the related-posts (Further Reading) sections, and also in the descriptive blurb in the home page.

So the code might go from this:

                {% include no-linenos.html content=post.content %}
                {{ content | markdownify | strip_html | truncate: 200 | escape }}

to this:

                (% if post.description %}
                       {{ post.description | markdownify | strip_html | truncate: 200 | escape }}
                {% else %}
                       {% include no-linenos.html content=post.content %}
                       {{ content | markdownify | strip_html | truncate: 200 | escape }}
                {% endif %}

@kungfux
Copy link
Collaborator

kungfux commented Mar 9, 2024

I think it's a great feature to have a description field in the front matter, as it can help work around this problem as well as #1516.

I would like to have this feature for my posts as well, to have control over the post description that appears in multiple places. I will work on it.

P.S. The originally reported issue should be fixed separately and I see no proper way to handle it so far.

@cotes2020
Copy link
Owner

cotes2020 commented Mar 14, 2024

Which version of Chirpy are you using?

Please fill in the software environment, and an example of Liquid code that can reproduce the issue. Otherwise it will be considered as an invalid report, thanks.

@kungfux
Copy link
Collaborator

kungfux commented Mar 15, 2024

I'm able to reproduce the problem reported on latest master branch. While @steveng57 is using custom HTML file to include some <head>'s, I have used video embedding to demo it below.

---
title: Writing a New Post
author: cotes
date: 2019-08-08 14:10:00 +0800
categories: [Blogging, Tutorial]
tags: [writing]
render_with_liquid: false
---

{% include embed/youtube.html id='Balreaj8Yqs' %}

image
image

@cotes2020
Copy link
Owner

@kungfux Note the special variable for that post:

---
render_with_liquid: false
---

If you comment out this line, Jekyll will render the liquid code

@kungfux
Copy link
Collaborator

kungfux commented Mar 15, 2024

If you comment out this line, Jekyll will render the liquid code

My bad. You're right. I made it in hurry cause I was pretty sure I reproduced it a few days back.

Now I see why do you ask to provide necessary details 😅

Thanks @cotes2020.

@steveng57
Copy link
Author

I updated my op with version details.

@cotes2020 cotes2020 added the invalid This doesn't seem right label Mar 22, 2024
@cotes2020 cotes2020 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2024
@cotes2020 cotes2020 pinned this issue Mar 23, 2024
@cotes2020 cotes2020 unpinned this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants