Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

Build fails when code contains Django template language (liquid tags) #498

Closed
stefanbschneider opened this issue Feb 1, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@stefanbschneider
Copy link

Required Prerequisites for filing a bug

You must follow ALL the steps in the troubleshooting guide. Not doing so may result in automatic closure of the issue.

Required information

  1. Steps to reproduce the problem

I'm using the latest version of fastpages to run my new blog.
On the blog, I want to write (among other stuff) about Django. Django's templates use syntax that is likely confused by Jekyll and that leads to build failures when using it in code snippets.

For example, including the following code snippet in a blog post leads to a build failure:

<form action="{% url 'helloworld:index' %}" method="post">
    {% csrf_token %}
    <button type="submit" name="hello-world-button">Greet the world!</button>
</form>

The action leads to the following error: Liquid Exception: Liquid syntax error (line 105): Unknown tag 'url' in /github/workspace/_posts/2021-01-29-django-db.md (see failed action).

When removing the code snippet from the blog post, it works fine.

This seems to be related to this issue, which is closed but apparently didn't solve the problem for me: #66

  1. A link to the notebook or markdown file where the error is occurring
  1. If the error is happening in GitHub Actions, a link to the specific error along with how you are able to reproduce this error. You must provide this in addition to the link to the notebook or markdown file.

Using the post with the Django code snippet, the action fails, eg, here.

Is there any recommendation how to deal with this other than just removing the snippet? I read something about {% raw %} tags around the snippet?

@stefanbschneider stefanbschneider added the bug Something isn't working label Feb 1, 2021
@github-actions
Copy link

github-actions bot commented Feb 1, 2021

Thank you for opening an issue. If this issue is related to a bug, please follow the steps and provide the information outlined in the Troubleshooting Guide. Failure to follow these instructions may result in automatic closing of this issue.

@stefanbschneider
Copy link
Author

A workaround could be to embed the code snippet as HTML using https://emgithub.com/ , but this isn't really handy for many code snippets.

@hamelsmu
Copy link
Member

hamelsmu commented Feb 1, 2021

You have to escape liquid tags

https://stackoverflow.com/questions/3426182/how-to-escape-liquid-template-tags

@hamelsmu hamelsmu closed this as completed Feb 1, 2021
@stefanbschneider
Copy link
Author

Thanks, putting {% raw %} and {% endraw %} around the code snippet solves the problem.

Just out of curiosity: Couldn't fastpages escape code blocks automatically?

@hamelsmu
Copy link
Member

hamelsmu commented Feb 2, 2021 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants