Link to repo: https://github.com/AlvSovereign/AlvSovereign.github.io

链接到回购:https://github.com/AlvSovereign/AlvSovereign.github.io

I am coding my portfolio site, with a link to my blog. The fully processed portfolio site sits in _site/index.html which contains a link to the blog (fully processed link exists in _site/blog.html)

我正在编写我的投资组合网站,并附有我的博客链接。完整处理的投资组合网站位于_site / index.html,其中包含指向博客的链接(_site / blog.html中存在完全处理的链接)

Blog.html at the root of the repo has in the front matter a layout of "bl", which is defined in my layouts folder under "bl.html".

在repo的根目录下的Blog.html在前面有一个“bl”的布局,它在我的layouts文件夹中的“bl.html”下定义。

"bl.html" is the layout I want for my blog page, which contains my includes etc. It also contains the {{ content }} liquid tag.

“bl.html”是我想要的博客页面的布局,其中包含我的包含等。它还包含{{content}}液体标签。

If I am thinking about this the right way, my posts are being parsed (I think this is the right terminology) into "post.html" - which has the front matter "layout: bl", which then parsed into "bl.html", and that this is so as they both have {{ content }} in each files.

如果我正在以正确的方式思考这个问题,我的帖子将被解析(我认为这是正确的术语)到“post.html” - 其中有前面的内容“layout:bl”,然后解析为“bl.html” “而且这是因为他们在每个文件中都有{{content}}。

Now all my posts are showing correctly (i think) within _site/(year)/(month) etc. However, they are not ending being parsed through my "blog.html" file, and then visible on my webpage. How I know this is that the fully processed "blog.html" file does not have any of the posts in them.

现在我的所有帖子都在_site /(year)/(month)等内正确显示(我认为)。但是,它们并没有通过我的“blog.html”文件解析,然后在我的网页上显示。我怎么知道这是完全处理的“blog.html”文件中没有任何帖子。

What will I need to do to solve this issue?

我需要做些什么才能解决这个问题?

If it helps, I use Prepros for LiveReload, and using LANYON template, http://lanyon.getpoole.com/

如果它有帮助,我使用Prepros for LiveReload,并使用LANYON模板,http://lanyon.getpoole.com/

1 个解决方案

#1


{{ content }} refers to all the content that in the file that is being converted to HTML code.

{{content}}指的是文件中转换为HTML代码的所有内容。

For example, if you are passing a blog post on 'What is Jekyll' to any layout that has the {{ content }} tag, all text other than the YAML front matter will be put in that place. Basically the content of the post. You can also limit the scope by using {{ post.content }}, see Variables for more info here.

例如,如果您将“What is Jekyll”上的博客文章传递给具有{{content}}标记的任何布局,则除YAML前端内容之外的所有文本都将放在该位置。基本上是帖子的内容。您还可以使用{{post.content}}限制范围,请参阅变量以获取更多信息。

So the Liquid {{ content }} variable works as intended.

因此Liquid {{content}}变量按预期工作。

Looking at your website, I believe you're trying to display all the posts in your blog.html file, so what you're actually asking about is why aren't my posts being displayed (not parsed) in your blog.html file, hence not visible on your webpage.

查看您的网站,我相信您正在尝试显示您的blog.html文件中的所有帖子,因此您实际询问的是为什么我的帖子不会在您的blog.html文件中显示(未解析)因此在您的网页上看不到。

The reason for that is because you shouldn't use {{ content }} tag for that, what you want instead is something like this snippet of code as mentioned in the Jekyll docs, that will grab all your posts, and display them by post title, as well as a link to that post. Here's the code to display a list of your posts. (taken from the website I linked you)

这样做的原因是你不应该使用{{content}}标签,你想要的是像Jekyll文档中提到的这段代码,它会抓取你的所有帖子,并通过帖子显示它们标题,以及该帖子的链接。这是显示帖子列表的代码。 (取自我链接到你的网站)

<ul>
{% for post in site.posts %}
    <li>
      <a href="{{ post.url }}">{{ post.title }}</a>
    </li>
  {% endfor %}
</ul>

So just swap out {{ content }} in your bl.html layout with that code snippet and you've got what you want.

因此,只需使用该代码段替换bl.html布局中的{{content}}即可获得所需内容。

Additionally, if you also want to display the content/excerpt in the list of posts, just add the liquid tag {{ post.content }} or {{post.excerpt}} like so:

此外,如果您还想在帖子列表中显示内容/摘录,只需添加液体标记{{post.content}}或{{post.excerpt}},如下所示:

<ul>
{% for post in site.posts %}
    <li>
      <a href="{{ post.url }}">{{ post.title }}</a>
      {{ post.content }} /* or post.excerpt */
    </li>
  {% endfor %}
</ul>

Of course, edit the HTML accordingly for your preference. Read the documentation on how to set up post excerpts here, which uses the <!--more--> comment separator for excerpts.

当然,根据您的偏好相应地编辑HTML。阅读有关如何在此处设置摘录的文档,其中使用 评论分隔符作为摘录。

I strongly recommend reading the JekyllRb documentation for more information, it's a lot to read and not always easily understandable, but keep referring to it and you'll understand more in no time.

我强烈建议您阅读JekyllRb文档以获取更多信息,这需要阅读很多,而且并不总是易于理解,但请继续参考它,您将立即了解更多信息。

更多相关文章

  1. c#生成html静态文件时出现空白行,怎么去掉utf-8中的bom
  2. 多文件拖拽上传以及利用Jquery替代HTML5上传控件
  3. 权限被拒绝:/var/www/abc/.htaccess pcfg_openfile:无法检查htacce
  4. 【CodeBase】PHP检查未知媒体文件的格式
  5. 用于检查用户名可用性的Javascript帖子无效
  6. 管理大量文件的提示?
  7. php 读取文本文件
  8. 如何打开名称中包含特殊字符的文件
  9. 如何将项添加到json文件格式化数组

随机推荐

  1. Android 与web的相互调用
  2. Android 自定义属性与xmlns
  3. 《Android深入透析》之Android事件分发机
  4. Android基础概念
  5. Android(安卓)ActionBar Item学习笔记
  6. Android开发常用代码片段(二)
  7. Android 启动过程详解
  8. (二)Android事件分发机制 - ViewGroup篇
  9. Android字体(一)
  10. Android消息循环实现原理分析