: 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
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?
More posts by @Cugini213
1 Comments
Sorted by latest first Latest Oldest Best
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.