问题
Is there a way to include an HTML partial from a Markdown file with Jekyll?
Example:
File index.md
:
---
layout: default
title: Home
---
This is a [Markdown](http://daringfireball.net/projects/markdown/) file.
{% include foobar.html %}
File _includes/foobar.html
:
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>
This unfortunately does not seem to work in my case.
For completeness, here is the entire content of my _config.yml
file:
encoding: utf-8
markdown: kramdown
baseurl:
回答1:
A common reason the html shows up as plain text is when the html snippet is indented with at least four spaces.
This causes jekyll to interpret the html as a code block that is to be displayed literally.
(I know this was already mentioned in the comments, but it took me a while to find and understand that I had the exact same problem)
来源:https://stackoverflow.com/questions/28030858/jekyll-include-html-partial-inside-markdown-file