html - Jekyll 包含转义结束标签?
问题描述
所以我有一个具有以下基本结构的站点:
<body>
<section>
<p>Text of Section 1</p>
</section>
<section>
<p>Text of Section 2</p>
</section>
...
</body>
我想使用 jekyll 从 markdown 文件生成整个网站,但由于 markdown 不知道任何类似部分的内容,我的想法是使用 markdown 作为普通文本,然后从另一个文件中包含缺少的 html,如下所示:
---
layout: default.html
---
Text of Section 1.
{% include sectionbreak.html %}
Text of Section 2.
为此,sectionbreak.html
必须包含类似
</section>
<section>
但是,jekyll
似乎会在包含文件的开头自动转义任何关闭的 html 标记,结果是一个更像这样的网站,彼此堆叠越来越多的部分:
<body>
<section>
<p>Text of Section 1</p>
<p></section></p>
<section>
<p>Text of Section 2</p>
...
</body>
有没有人知道如何禁用这种行为,或者做什么来生成网站?
解决方案
这是每一页的事情吗?或者只是一个专业的头版?我不明白你为什么要创建这样的常规日常帖子,但我已经为我的首页做了这个,我有这样的东西:
|-...
|- _landing
|- intro.md
|- blog.md
|- projects.md
|- index.html
在我index.hml
的主页中,我拉入按 ._landing
排序的所有集合frontmatter.index
。它可以让您重新排序并将部分添加到您的主页,其中landing/blog.md
仅包含最新的 5-10 个条目和一个链接,pages/archive.html
其中包含完整的分页帖子列表。
同样,我不会对您网站上的每个页面都建议这样做,但它适用于我数量有限的专业页面。像:
- 具有多个链接到整页的摘要部分的索引/登录页面
- 具有多个联系部分的联系页面
编辑
对于冰雹玛丽来说,这个怎么样,如果不通过 jekyll 源,我不知道它是否会起作用,但是:
{% assign sections = page.content | split:"<!-- SPLIT -->" %}
{% for section in sections %}
<section>
{{ section }}
</section>
<banner>
</banner>
{% endfor %}
快速谷歌表明这可能不像我想象的那么疯狂:https ://gist.github.com/Phlow/04f635e4d1fc928b1157
推荐阅读
- spring - 为什么spring集成中默认的“errorChannel”是“PublishSubscribeChannel”?
- excel - 通过 Windows 身份验证通过宏 Excel 运行 SQL 作业代理
- python - 在两个用户模型之间创建关系
- swift - 在 SwiftUI 中使用泛型作为函数属性的默认值
- javascript - PHP laravel 和 JQuery AJAX 追加表单输入
- c++ - c ++如何在构造函数中初始化char
- ruby - 尝试使用 Oauth 1.0 获取 Twitter request_token 不断给出“215 Bad Authentication”错误
- firebase - 带有过滤器实现的颤动分页
- vim - 文件类型插件如何加载更改
- javascript - 如何在使用Javascript计算时在字段中没有输入值时删除NaN