使用Jekyll,如何在不是帖子或页面的布局中组织/放置段落数据? [英] Using Jekyll, how to organize/place paragraph data within layout that is not post or page?

查看:97
本文介绍了使用Jekyll,如何在不是帖子或页面的布局中组织/放置段落数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Jekyll的第一天,我基本上有了Jekyll的最低主题,我正在修改此主题以尝试创建一个新站点.

First day with Jekyll, I basically have the minima theme from Jekyll that I'm modifying trying to create a new site.

我在_layouts中有一个home.html.我的目标是将段落并排放置在3个单独的列中.我的理解是_layouts和_includes主要用于格式化,至少我是这样看的.我知道可以在这些文件中显示一堆静态文本,但是如果要显示的文本位于_pages文件夹中,则看起来更干净(更容易编辑).但是,这样做当然会在标头中创建一个新链接.因此,我试图找到一种方法来插入markdown文件,该文件只是可以完全插入到主主页中的文本段落.

I have a home.html within _layouts. My goal is to place paragraphs within 3 individual columns, side-by-side. My understanding is that _layouts and _includes are mainly for formatting, at least that's how I look at them. I aware one can put a bunch of static text to display within these files, but it seems cleaner (and easier to edit) if the text to display were in something like a _pages folder. But of course doing so creates a new link in the header. So I am trying to find a way insert a markdown file which is just paragraphs of text that I can cleanly insert into my main home page, and only there.

仅在插入布局或包含中但不将其直接写入布局或包含中,也不使其成为帖子或页面,或使用_data中的变量的唯一目的是如何以及在何处放置标记(段落大小) .我希望制作一个Markdown文件,目的是为了比帖子,页面等小.

How and where does one place markdown (paragraph sizes) for the sole purpose of inserting into layouts or includes, but not writing them directly into the layout or include, nor making it a post or a page, or using variables within _data. I was hoping to make a markdown file for smaller purposes than posts, pages, etc...

我的_layouts/home.html如下所示,但降价未显示. IIRC,这是因为include只能访问_includes,而我希望不必在_includes或html的内部写入此数据.

My _layouts/home.html looks as follows, but the markdown isn't showing up. IIRC, this is because includes can only access _includes, and I was hoping not to have to write this data within _includes or html's.

---
layout: default
---

<div class="home">
    <div class="home-col-wrapper">
        <div class="home-col home-col-1">
            {% include front-col-1.md %}
        </div>
    </div>

    <div class="home-col home-col-2">
            {% include front-col-2.md %}
        column 2
    </div>

    <div class="home-col home-col-3">
            {% include front-col-3.md %}
        column 3
    </div>
</div>

我还尝试将* .md文件放在_pages中,并将布局更改为home,但无济于事.文本未显示在首页布局中.

I also tried putting an *.md file in _pages and changing the layout to home, but to no avail. The text didn't show up in the home layout.

---
layout: home
---

A bunch of stuff should probably go here. So be sure to make sure it looks ok. ok? ok! 

推荐答案

我刚刚做了类似的事情.如果我正确理解了您的问题,那么您要做的就是将{% include front-col-1.md %}替换为

I just did something similar. If I understand your question correctly, all you need to do is to replace {% include front-col-1.md %} by

{% capture temp %}{% include front-col-1.md %}{% endcapture %}
{{ temp  | markdownify }}

发生的情况是Liquid捕获了变量temp中的markdown文件,然后markdownify将其转换为HTML并添加了它.

What happens is that Liquid captures the markdown file in the variable temp, and then markdownify converts it into HTML and adds it.

我认为您不能将markdown文件放在其他位置,但是它们必须位于_includes中.

I don't think you can put the markdown files elsewhere, but they need to be in _includes.

相关: https://github.com/jekyll/jekyll-help/issues /51

这篇关于使用Jekyll,如何在不是帖子或页面的布局中组织/放置段落数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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