1

I have setup a Github page successfully using Jekyll and the default Minimal theme on the gh-pages branch. It acts as a nice documentation for my code in the master branch. However I now want it to also render a custom html page.

What do I mean by that?
The html is a completely finished page that doesn't need a template but still needs to be output.

Usually we write in markdown and Github takes care of everything. But this custom html file can't be prepared that way. It has some interactive elements, scripts etc that can't be put down in markdown and expected to be prepared correctly by Github (OR is it actually possible to hack the template to do that?). I don't really care the endpoint of the page, it can be any thing.

If it can be done, please let me know how.

EDIT:

Using the current solution of -

---

---
<html>
.
.
</html>

I am able to partially render the HTML file i.e the formatting of the template is still applied even though I do not want any formatting from the theme at all.

How do I make Github ignore all formatting from the theme for just this html file ?

EDIT2:

I also tried with the following in assets/css/style.scss file based on customizing your theme's css help -

---
---

@import "{{ site.theme }}";
.title{}
.body{}
.div{}

But nothing happened.

EDIT3

I haven't tried with customizing your html layout yet, but that also seems to be a solution.

I also tried with the following directly in the index.md file -

---
layout: doom
---

Where doom is NOT defined anywhere.
This seems to work !!

4

1 回答 1

1

在 Jekyll 中使用 front matter的文档有一个说明,其中指定了以下内容:

如果你想使用 Liquid 标签和变量,但在前面的内容中不需要任何东西,只需将其留空!中间没有任何内容的三重虚线集仍然可以让 Jekyll 处理您的文件。

所以在你的 html 文件的顶部,你可以有以下内容:

---
---

<html>
    <head>
    ....
</html>

Jekyll 将处理该文件,因为它看到了这组行。它不会应用任何东西,因为行内没有任何内容。之后,输出 url 可能会遵循该文件所在位置的文件结构。

编辑

如果你不希望 Jekyll 添加主题,你可以有一个完全空的布局文件,并在自定义 html 页面的前端使用该布局。

//_layouts/empty.html
{{content}}
//customPage.html
---
layout: empty
---

<html>
    <head>
    ....
</html>
于 2019-10-15T05:39:12.550 回答