【问题标题】:Jekyll: page not found after insert front matterJekyll:插入前面的内容后找不到页面
【发布时间】:2020-10-28 14:08:57
【问题描述】:

我开始制作 github.io 投资组合和博客网站。这是我人生中的第一次…… 我目前制作网页的过程:

  1. 选择并下载有吸引力的模板。(完成。它有主页、包含项目链接的投资组合页面和包含一般博客文章的博客页面)
  2. 应用 Jekyll 风格,修改页面和基本文件夹,如 _posts、_layouts、_includes 等。(我红了很多帖子,Jekyll 官方介绍。)
  3. 为了测试我的页面,我安装了 Ruby 和 gems。我输入了bundle exec jekyll serve,它与我的index.html 和原始(不转换为液体类型)blog.html 一起使用。
  4. 我复制了blog.html 的代码并将其粘贴到_layouts/bloglayout.html 并更改了blog.html,就像下一个代码一样。 然后,我每次点击导航栏上的博客时都会出现 404 page not found 错误
<!--/blog.html-->
---
# this is liquid page
layout: blog_layout
---
<!--/_layouts/bloglayout.html-->
<!DOCTYPE html>
<!--[if lt IE 8 ]><html class="no-js ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="no-js ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 8)|!(IE)]><!--><html class="no-js" lang="ko"> <!--<![endif]-->
    {% include head.html %}

<body>

   {% include header.html %}

   <!-- Page Title
   ================================================== -->
   <!-- Page Title End-->

   <!-- Content
   ================================================== -->
    <!-- Content End-->

   {% include footer.html %}
   {% include scripts.html %}

</body>

</html>

我花了半天时间研究这个错误,但无法找到原因.. 你能给我任何线索吗...?

这是我的 github 存储库:Juyeon-Lee.github.io

【问题讨论】:

    标签: html layout jekyll liquid


    【解决方案1】:

    1-从https://juyeon-lee.github.io/blog/之类的链接中删除.html,问题404将得到解决 2-您必须添加{{ content }}

    <!DOCTYPE html>
    <!--[if lt IE 8 ]><html class="no-js ie ie7" lang="en"> <![endif]-->
    <!--[if IE 8 ]><html class="no-js ie ie8" lang="en"> <![endif]-->
    <!--[if (gte IE 8)|!(IE)]><!--><html class="no-js" lang="ko"> <!--<![endif]-->
        {% include head.html %}
    <body>
    
        {% include header.html %}
    
        {{ content }}
    
        {% include footer.html %}
        {% include scripts.html %}
    </body>
    </html>
    

    3- 添加到 blog.html

    ---
    layout: blog_layout
    ---
    

    【讨论】:

    • 感谢您回答的 3 个确切步骤~!!!! :) 差点就放弃了,不过为了以防万一,一大早就来了这个网站,很高兴有这么精彩的回答。祝你有美好的一天!
    • &lt;ul&gt; {% for post in site.posts %} &lt;li&gt; &lt;a href="{{ post.url }}"&gt;{{ post.title }}&lt;/a&gt; &lt;/li&gt; {% endfor %} &lt;/ul&gt; 添加到 blog.html 以显示帖子
    • 我已经做到了,但是谢谢!!! :) 即使在这寒冷的天气里,你的心也温暖了我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-31
    • 1970-01-01
    相关资源
    最近更新 更多