I am pretty new to websites with Jekyll hosted on Github, and I was wondering if there was a neat way to include the contents of a markdown page (say this one) into a post (say this one) in order to always have the contents up to date if the source page is modified?

1 Answer 1


Breno Salgado posted this simple Jekyll plugin on StackOverflow:


module Jekyll
  class MarkdownTag < Liquid::Tag
    def initialize(tag_name, text, tokens)
      @text = text.strip
    require "kramdown"
    def render(context)
      "#{Kramdown::Document.new(File.read(File.join(Dir.pwd, '_includes', @text))).to_html}"
Liquid::Template.register_tag('markdown', Jekyll::MarkdownTag)

According to this page you should be able to use code like this:

{% markdown test.md %}

To render the contents of the markdown file.

  • Great, thank you for that, I managed to set it up. However, because the files I want to include are in a different repo (but same project), how do I tell Jekyll to look for them there (and not just in '_includes'), without having to create a submodule?
    – stragu
    Jun 20, 2014 at 5:01
  • At the end, it is not possible to use a custom plugin on GitHub Pages because they override parts of _config.yml to always enable the Jekyll safe mode (and therefore only allow the few plugins supported by GitHub). I will have to find a different solution...
    – stragu
    Jun 20, 2014 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.