Jekyll 在 Github Pages 中使用 index.html 时不渲染主题布局

问题描述

我正在尝试学习如何使用 Github 页面,因此我创建了我的第一个页面添加Jekyll cayman 主题

添加主题之前,我可以只使用 index.html 文件来呈现我的主页。但是,现在我添加了 cayman 主题,不再读取 index.html 文件,只读取 index.md 文件

产生的github页面
https://scinana.github.io/hellopages/

代码
https://github.com/scinana/hellopages

为什么我必须添加 index.md 文件

如果我想继续直接使用 html 文件而不是 md 文件怎么办?我可以在使用 Jekyll 主题的同时使用 html 文件吗?

解决方法

您可以使用 html 文件。只需添加前端内容并插入默认布局即可。

这是一个例子:

---
layout: default
---
  
<!doctype html>
<html>
  <head>
    <title>This is the title of the webpage!</title>
  </head>
  <body>
    <p>This is an example paragraph. Anything in the <strong>body</strong> tag will appear on the page,just like this <strong>p</strong> tag and its contents.</p>
  </body>
</html>

来自https://jekyllrb.com/docs/step-by-step/04-layouts/

布局是您网站中任何页面都可以使用的模板,可以环绕页面内容。它们存储在名为 _layouts 的目录中。

来自https://jekyllrb.com/docs/structure/

index.html 或 index.md 和其他 HTML、Markdown 文件
如果文件有前端部分,它将被 Jekyll 转换。对于站点根目录或上面未列出的目录中的任何 .html.markdown.md.textile 文件,都会发生同样的情况。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...