Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Jekyll在帖子布局中动态添加新的部分?_Html_Twitter Bootstrap 3_Jekyll_Liquid - Fatal编程技术网

Html Jekyll在帖子布局中动态添加新的部分?

Html Jekyll在帖子布局中动态添加新的部分?,html,twitter-bootstrap-3,jekyll,liquid,Html,Twitter Bootstrap 3,Jekyll,Liquid,我刚刚在Jekyll中创建了一个公文包集合,并在我的单个项目.html布局中使用了简单的流动语法,成功地包含了额外的html部分 这些额外的html节起到了解救作用,因此单个项目的页面内容不必显式地驻留在为{{content}变量定义的唯一容器/包装器中 因此(从视觉上讲),我可以将任何html内容放在中,并以单个项目的方式对其进行相应的样式设置。html布局可以使用全宽容器/元素等进行丰富。但是,我一直在考虑只在{{content}变量上方和下方注入全幅内容的可能性 在Jekyll中实现动态布

我刚刚在Jekyll中创建了一个公文包集合,并在我的
单个项目.html
布局中使用了简单的流动语法,成功地包含了额外的html部分

这些额外的html节起到了解救作用,因此单个项目的页面内容不必显式地驻留在为
{{content}
变量定义的唯一容器/包装器中

因此(从视觉上讲),我可以将任何html内容放在
中,并以
单个项目的方式对其进行相应的样式设置。html
布局可以使用全宽容器/元素等进行丰富。但是,我一直在考虑只在{{content}变量上方和下方注入全幅内容的可能性

在Jekyll中实现动态布局结构以包括页面上的部分,是否有一个变通方法


project.md文档中

对于每个我想要有额外html部分的项目,我在文档的前端定义了我在
单个项目.html
布局中要使用的html文件的名称

---
### Project Details
layout: project
title: Cards Mockup project

# Project Extra Sections
sections_top:
  sections: ['section-intro.html', 'section-services-provided.html']
#
sections_bottom:
  sections: ['section-fullwidth-figure.html']
---

single project.html布局中

我有条件地包括前面在每个文档前面提供的html部分,如以下内容:

<div class="main-container">
{% if page.sections_top %}
<div class="container-fluid no-pad">
{% assign sections_top = page.sections_top['sections'] %}
 {% for section in sections_top %}
  {% include {{ section }} %}
 {% endfor %}
</div>
{% endif %}


<!-- Section main content -->
<section class="article-body">

<div class="container">
 <div class="row">
  <div class="col-sm-12">
  {{ content }}
  </div>
 </div>
</div><!-- end .container -->                 

</section><!-- end section main content -->

{% if page.sections_bottom %}
<div class="container-fluid no-pad">
{% assign sections_bottom = page.sections_bottom['sections'] %}
 {% for section in sections_bottom %}
  {% include {{ section }} %}
 {% endfor %}
</div>
{% endif %}

</div><!-- end .main-container --> 

{%if page.sections_top%}
{%assign sections\u top=page.sections\u top['sections']%}
{sections_top%}
{%include{{section}}%}
{%endfor%}
{%endif%}
{{content}}
{%if page.sections_bottom%}
{%assign sections\u bottom=page.sections\u bottom['sections']%}
{u bottom%}
{%include{{section}}%}
{%endfor%}
{%endif%}

这是一个屏幕截图:(全幅图像之间的所有内容都是{{content}},全幅图像是html部分。

我想你想要这样的东西:

您可以用{{content}}标记替换其中一个include


如果你(真的)要让内容编辑器能够选择节及其顺序,您必须在.md文件的顶部创建一个带有节名称的YAML数组,并在其中循环。

您是否只需要在标记内容中包含节?如
…content…
?如果只是它,您可以直接执行,如本文所述虽然我可以直接插入结构化html,但它仍然与标记(待处理)绑定,并通过
{{content}输出
变量,因此我需要复制/粘贴并手动更改在特定页面上插入的每个html节。我真正想要实现的是通过使用动态html节(从文档的首页抓取内容)完全模板化页面的方法不需要在每个标记文档中乱用html。我认为我现在已经采用的方法可以满足我现在的模板需求,我的意思是我可以通过(包括)我想要的html部分来构建一个完整的页面,同时将每个文档的标记保留为空,这样
{content}
变量将输出“nothing”。这种解决方法会导致页面上的html部分具有流动性逻辑意识,因此在每个页面上。标记文档的首要问题我会定义变量,用每个项目页面所需的内容填充这些部分。我想我理解你的意思。但是,你的流动性标记工作不正常?嗯,如果首要问题是comi从帖子中,你应该使用“{%if post.something%}`而不是
页面
,明白吗?对于你的yaml,你可以这样使用:
标题:“一些复杂的东西”
当你处理特殊角色时。但我不确定我是否回答了你的问题…你也可以使用Jekyll
包含到你的模板中。