Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Jekyll Markdown Tag
Jekyll tag to include Markdown text from _includes directory preprocessing with Liquid.
{% markdown <filename> %}
- kramdown
module Jekyll
class MarkdownTag < Liquid::Tag
def initialize(tag_name, text, tokens)
@text = text.strip
require "kramdown"
def render(context)
tmpl = File.join Dir.pwd, "_includes", @text
site = context.registers[:site]
tmpl = (Liquid::Template.parse tmpl).render site.site_payload
html =
Liquid::Template.register_tag('markdown', Jekyll::MarkdownTag)

This comment has been minimized.

Copy link

@dr3s dr3s commented Jul 24, 2013

neither this nor render_partial work for me


This comment has been minimized.

Copy link

@mignev mignev commented Dec 2, 2013

Hi thanks for the gist :) I fork it and make some small change to work with markdown engine that your Jekyll installation works :) ... i mean without other dependencies. This is the link of my gist:

Thanks once again :)


This comment has been minimized.

Copy link

@moble moble commented Nov 7, 2014

I've mentioned this on @mignev's fork, but it also applies to this version:

Something weird seems to happen to the markdown with this plugin. For example, when using fenced code blocks, the newlines seem to disappear. I've also added support for MathJax to my installation, and the backslashes get removed. Explicit inclusion along the lines of

{% capture my-include %}{% include %}{% endcapture %}
{{ my-include | markdownify }}

Doesn't have these problems. Any ideas how to work around these while still using the plugin?


This comment has been minimized.

Copy link

@kristiannordestgaard kristiannordestgaard commented Aug 13, 2015


This is my current code:

{% if member.brief %}
{% include /briefs/{{ member.brief }} %}
{% endif %}

I need to change this so it uses the markdown command instead of include, but

{% if member.brief %}
{% markdown /briefs/{{ member.brief }} %}
{% endif %}

Gives me a "file not found" error. How can I make it work?



This comment has been minimized.

Copy link

@kamlekar kamlekar commented Aug 27, 2015

Even after inserting this code in _plugins directory, I am getting page build error:

The tag markdown in _posts/ is not a recognized Liquid tag.

I am using kramdown markdown.

Please help.


This comment has been minimized.

Copy link

@c100k c100k commented Nov 15, 2015

@kamlekar I've just had the same problem. I forgot to restart my site with jekyll serve.


This comment has been minimized.

Copy link

@apburton84 apburton84 commented Feb 19, 2016

How would variables be passed into the included markdown ?

{% markdown param="value" %}

Liquid Exception: No such file or directory - _includes/ param="value" in _posts/2016-01-22-user.markdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.