问题描述
我有一组markdown文件,我想在构建页面时使用两个不同的布局文件来渲染两个不同的文件集:
I have a collection of markdown files and I would like to render in two different set of files using two different layout files when building the page:
–网站的html文件– xml文件
– html files for the website– xml files
是否可以这样做?降价文件似乎只能解析一次.有什么建议?非常感谢
Is it possible to do this? It seems that a markdown file can be only parsed once. Any suggestions? Many thanks
推荐答案
您将需要两个页面来指向markdown发布文件,而不是拥有一个指向布局文件的markdown文件.
Instead of having a markdown file that points to a layout file, you're going to need two pages that point to the markdown post file.
有多种方法可以指向发布文件.我喜欢使用where
过滤器:
There are a number of ways to point to a post file. I like to use a where
filter:
{% assign post = site.posts | where:"url", include.url | first %}
现在您有一个post
,假设您有要放入该帖子的fileOne.html
.这是您的处理方式:
Now that you have a post
, let's say you have fileOne.html
that you want to put that post into. Here's how you'd approach that:
---
layout:main
---
<h1>Some html here</h1>
{% assign post = site.posts | where:"url", include.url | first %}
{{ post.content }}
然后,您可以在另一个名为fileTwo.html
的文件中执行完全相同的操作.
Then you could do the exact same thing in another file named fileTwo.html
.
这篇关于如何从单个Markdown渲染两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!