Mobile app version of vmapp.org
Login or Join
Cugini213

: How to include the contents of a markdown page into a post with Jekyll? I am pretty new to websites with Jekyll hosted on Github, and I was wondering if there was a neat way to include

@Cugini213

Posted in: #Github #Jekyll #Markdown

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cugini213

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

Breno Salgado posted this simple Jekyll plugin on StackOverflow:

./_plugins/markdown_tag.rb:

module Jekyll
class MarkdownTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text.strip
end
require "kramdown"
def render(context)
"#{Kramdown::Document.new(File.read(File.join(Dir.pwd, '_includes', @text ))).to_html}"
end
end
end
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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme