Jekyll:在Markdown文件中包括HTML部分 [英] Jekyll: Include HTML partial inside Markdown file

查看:130
本文介绍了Jekyll:在Markdown文件中包括HTML部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过Jekyll包含Markdown文件中的HTML部分?

Is there a way to include an HTML partial from a Markdown file with Jekyll?

示例:

文件index.md:

---
layout: default
title: Home
---

This is a [Markdown](http://daringfireball.net/projects/markdown/) file.

{% include foobar.html %}

文件_includes/foobar.html:

<ul>
    <li>Foo</li>
    <li>Bar</li>
</ul>

不幸的是,这似乎不适用于我的情况.

This unfortunately does not seem to work in my case.

为完整起见,这是我的_config.yml文件的全部内容:

For completeness, here is the entire content of my _config.yml file:

encoding: utf-8
markdown: kramdown
baseurl: 

推荐答案

html显示为纯文本的一个常见原因是当html代码段缩进至少四个空格时.

A common reason the html shows up as plain text is when the html snippet is indented with at least four spaces.

这会使jekyll将html解释为要按字面显示的代码块.

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)

这篇关于Jekyll:在Markdown文件中包括HTML部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆