Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include "{% %}" in markdown file when using jekyll?

I am using Jekyll to post blogs. When I write "{%...%}" in my markdown files, it seems that the "{%...%}" will be parsed by Liquid. But sometimes that is not what I want, and may cause errors. So what's the proper way to include texts like "{%...%}" in my post content(the .md file)?

I checked the Liquid docs and learned I can use the Block Tag {% raw %} ... {% end raw %} to include raw text between. However, I don't think this a good idea. Because if the markdown file was not parsed by Liquid (e.g., in some environment other than Jekyll), this will leave unused {% raw %} in my text.

Correct me if I said something wrong.

P.S.: I use GitHub Pages for hosting and they disable plugins.

like image 489
shengbinmeng Avatar asked Jul 18 '13 09:07

shengbinmeng


People also ask

Does Jekyll support Markdown?

Jekyll supports Markdown in addition to HTML when building pages. Markdown is a great choice for pages with a simple content structure (just paragraphs, headings and images), as it's less verbose than raw HTML.

What is the _site folder in Jekyll?

This is where the generated site will be placed (by default) once Jekyll is done transforming it.

Where do I put pictures in Jekyll?

Create /assets/images/ in the root of your project and place the image there. And if you're not hosting with GitHub Pages you can use the Jekyll Post Files plugin which allows you to organize your images alongside your posts. Don't use underscores in your folder names.


2 Answers

One thing to remember about Jekyll and GitHub pages is that you can always build your site locally (by running jekyll build), commit it to your repo and have GitHub serve it from there. So you can use (or create) a plugin that'll enable you to have what you want. :P

On the other hand, I think it's really too much trouble to not use the {% raw %}. If -- and only if -- you're going to use these markdown files somewhere else, you can pass them through a script (or a sed command) and sweep away these tags.

like image 104
agarie Avatar answered Oct 17 '22 14:10

agarie


You could use HTML entities { and } for { and }. Not the tidiest but it doesn't use {% raw %} or rely on plugins.

like image 31
RobertKenny Avatar answered Oct 17 '22 15:10

RobertKenny