使用带有Jekyll主题的每页标题

使用带有Jekyll主题的每页标题,jekyll,github-pages,jekyll-theme,Jekyll,Github Pages,Jekyll Theme,这是我的个人主页 我在我的/\u config.yml中设置了此项: theme: jekyll-theme-cayman title: iBug @ GitHub description: The small personal site for iBug 现在,它显示了一个大标题iBug@GitHub和GH页面生成的每一页上的标语。我想为特定页面设置覆盖。我试过了 --- title: Blog index --- 在/blog/index.html中,但它不起作用。它只更改页面的HTM

这是我的个人主页

我在我的
/\u config.yml
中设置了此项:

theme: jekyll-theme-cayman

title: iBug @ GitHub
description: The small personal site for iBug
现在,它显示了一个大标题iBug@GitHub和GH页面生成的每一页上的标语。我想为特定页面设置覆盖。我试过了

---
title: Blog index
---
/blog/index.html
中,但它不起作用。它只更改页面的HTML标题(浏览器标题栏),而不更改页面顶部大块中的“标题”


如何为单个页面设置覆盖标题?

这正是该主题的实现方式,如果您在上检查Cayman主题的默认布局,您可以看到它使用的确切变量

<h1 class="project-name">{{ site.title | default: site.github.repository_name }}</h1>
{{site.title |默认值:site.github.repository_name}

希望有帮助

更新:我已经提交了一个拉取请求来更改主题,下面的答案不再是必需的,因为它已经在您使用主题时应用。您需要做的只是在前面的内容中指定标题替代:

---
title: My custom title
---

要指定其他标题,需要更改布局文件

复制并将其放置在
/\u layouts/default.html
中,并将第16行更改为:

<h1 class="project-name">{{ page.title | default: site.title }}</h1>
{{page.title}默认值:site.title}

然后,Jekyll将尊重前面设置的
标题,并将其放在那里。

我的方法是使用javascript,如下所示

<script>
    document.getElementsByClassName("project-name").item(0).innerText = "{{ page.title }}";
</script>

document.getElementsByClassName(“项目名称”).item(0.innerText=“{{page.title}}”;
您可以在
\u includes
目录中编写html文件,并立即使用
{%includes your_file.html%}
{{page.title |默认:site.title |默认:site.github.repository\u name}