包含分页变量的 jekyll 博客标题
jekyll blog title to include pagination variables
我正在尝试让我博客的第 2+ 页具有不同的标题,以便搜索引擎编制索引。
我已经阅读了其他几个 Whosebug 答案,指出您不能在 front matter yaml 中使用 liquid 标签。有人建议使用 JS 来更新标题,但是这对我不起作用,因为我希望搜索引擎索引解析后的标题。
我想可能还有别的办法。我或许可以为我的每个页面创建一个 HTML 页面。我想这样做而不必手动将我的每个 post 添加到每个页面(每次我 post 一篇新文章时都会导致持续耗时的任务)。
我在想我可以为 1-10 制作一页,为 11-20 制作另一页,等等...像这样:
---
title: Blog Page 2
---
{% for post in paginator.posts %}
{% if post.index > 10 %}{% if post.index <= 20 %}
<div class="post-preview">
<a href="{{ post.url | prepend: site.baseurl }}">
<h2 class="post-title"> {{ post.title }}</h2>
{{ post.excerpt }}
</a>
</div>
{% endif %}{% endif %}
{% endfor %}
似乎没有可用的 post.index 变量。我可以使用类似的东西吗?
或者还有其他方法可以实现我标题中的"Blog Page X"吗?
假设您的 head 标签在您的 _includes/head.html 文件中。在 title
标签中添加:
{% if paginator %} - page {{ paginator.page }}{% endif %}
您的标题标签现在如下所示:
<title>
{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}
{%if paginator %} - page {{ paginator.page }}{% endif %}
</title>
我正在尝试让我博客的第 2+ 页具有不同的标题,以便搜索引擎编制索引。
我已经阅读了其他几个 Whosebug 答案,指出您不能在 front matter yaml 中使用 liquid 标签。有人建议使用 JS 来更新标题,但是这对我不起作用,因为我希望搜索引擎索引解析后的标题。
我想可能还有别的办法。我或许可以为我的每个页面创建一个 HTML 页面。我想这样做而不必手动将我的每个 post 添加到每个页面(每次我 post 一篇新文章时都会导致持续耗时的任务)。
我在想我可以为 1-10 制作一页,为 11-20 制作另一页,等等...像这样:
---
title: Blog Page 2
---
{% for post in paginator.posts %}
{% if post.index > 10 %}{% if post.index <= 20 %}
<div class="post-preview">
<a href="{{ post.url | prepend: site.baseurl }}">
<h2 class="post-title"> {{ post.title }}</h2>
{{ post.excerpt }}
</a>
</div>
{% endif %}{% endif %}
{% endfor %}
似乎没有可用的 post.index 变量。我可以使用类似的东西吗?
或者还有其他方法可以实现我标题中的"Blog Page X"吗?
假设您的 head 标签在您的 _includes/head.html 文件中。在 title
标签中添加:
{% if paginator %} - page {{ paginator.page }}{% endif %}
您的标题标签现在如下所示:
<title>
{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}
{%if paginator %} - page {{ paginator.page }}{% endif %}
</title>