Jekyll 分页导航到错误的页面
Jekyll pagination navigates to wrong page
问题:您可以点击“旧”进入旧博客的第二页,即https://www.bgigurtsis.com/blog/page2/. However, clicking on ‘Newer’ once on that second page takes you to the homepage https://www.bgigurtsis.com, as opposed to the page you were just on https://www.bgigurtsis.com/blog
我制作了这个 GIF 来说明这个问题:https://i.imgur.com/JN9qXoN.gif
我的设置 我正在使用托管在 AWS Amplify 上的 Jekyll 主题。通常对于这个主题,索引页面是所有博客 post 所在的位置。我对此进行了更改,因此索引页面是一个“欢迎”post,并带有指向博客的超链接。
实现这个:
- 我将 index.html(分页代码)从我的根目录移动到一个文件夹中
称为“博客”
- 在我的根目录中添加了一个 index.md(欢迎页面)。
- 将此代码添加到我的 _config.yml:paginate_path:“/blog/page:num”
文件夹结构如下:
website
├── config.yml
├── index.md (welcome post)
├── blog
├── index.html (paginate code)
│
├── posts
├── post1.md
├── post2.md
├── post3.md
├── post4.md
├── post5.md
我的 _config.yml 构建设置:
# Build settings
markdown: kramdown
redcarpet:
extensions: ['smart', 'tables', 'with_toc_data']
permalink: /blog/:title
paginate_path: "/blog/page:num"
paginate: 4
这是我的分页代码,包含在 blog/index.html:
---
layout: default
---
{% assign posts_count = paginator.posts | size %}
<div class="home">
{% if posts_count > 0 %}
<div class="posts">
{% for post in paginator.posts %}
<div class="post py3">
<p class="post-meta">
{% if site.date_format %}
{{ post.date | date: site.date_format }}
{% else %}
{{ post.date | date: "%b %-d, %Y" }}
{% endif %}
</p>
<a href="{{ post.url | relative_url }}" class="post-link"><h3 class="h1 post-title">{{ post.title }}</h3></a>
<span class="post-summary">
{% if post.summary %}
{{ post.summary }}
{% else %}
{{ post.excerpt }}
{% endif %}
</span>
</div>
{% endfor %}
</div>
{% include pagination.html %}
{% else %}
<h1 class='center'>{{ site.text.index.coming_soon }}</h1>
{% endif %}
</div>
我博客的主页在这里bgigurtsis.com
博客的 repistory 在这里bgigurtsis/blog
分页将按钮“Older”链接到我的主页而不是我博客的第一页。分页似乎不知道 bgigurtsis 点 com/blog 是博客 post 的第一页,但我不确定如何解决这个问题。有什么想法吗?
谢谢!
在 ./_includes/pagination.html 它告诉分页在转到较新的帖子时导航到哪里。默认情况下,这设置为 / 当您的博客文章通常是这样时,它会起作用。我只是将其更改为 /blog.
完整的变化可以在这里看到:
https://github.com/bgigurtsis/blog/commit/72f6210518551b8983a27ef2bf44bf67028b6b4f
问题:您可以点击“旧”进入旧博客的第二页,即https://www.bgigurtsis.com/blog/page2/. However, clicking on ‘Newer’ once on that second page takes you to the homepage https://www.bgigurtsis.com, as opposed to the page you were just on https://www.bgigurtsis.com/blog
我制作了这个 GIF 来说明这个问题:https://i.imgur.com/JN9qXoN.gif
我的设置 我正在使用托管在 AWS Amplify 上的 Jekyll 主题。通常对于这个主题,索引页面是所有博客 post 所在的位置。我对此进行了更改,因此索引页面是一个“欢迎”post,并带有指向博客的超链接。
实现这个:
- 我将 index.html(分页代码)从我的根目录移动到一个文件夹中 称为“博客”
- 在我的根目录中添加了一个 index.md(欢迎页面)。
- 将此代码添加到我的 _config.yml:paginate_path:“/blog/page:num”
文件夹结构如下:
website
├── config.yml
├── index.md (welcome post)
├── blog
├── index.html (paginate code)
│
├── posts
├── post1.md
├── post2.md
├── post3.md
├── post4.md
├── post5.md
我的 _config.yml 构建设置:
# Build settings
markdown: kramdown
redcarpet:
extensions: ['smart', 'tables', 'with_toc_data']
permalink: /blog/:title
paginate_path: "/blog/page:num"
paginate: 4
这是我的分页代码,包含在 blog/index.html:
---
layout: default
---
{% assign posts_count = paginator.posts | size %}
<div class="home">
{% if posts_count > 0 %}
<div class="posts">
{% for post in paginator.posts %}
<div class="post py3">
<p class="post-meta">
{% if site.date_format %}
{{ post.date | date: site.date_format }}
{% else %}
{{ post.date | date: "%b %-d, %Y" }}
{% endif %}
</p>
<a href="{{ post.url | relative_url }}" class="post-link"><h3 class="h1 post-title">{{ post.title }}</h3></a>
<span class="post-summary">
{% if post.summary %}
{{ post.summary }}
{% else %}
{{ post.excerpt }}
{% endif %}
</span>
</div>
{% endfor %}
</div>
{% include pagination.html %}
{% else %}
<h1 class='center'>{{ site.text.index.coming_soon }}</h1>
{% endif %}
</div>
我博客的主页在这里bgigurtsis.com
博客的 repistory 在这里bgigurtsis/blog
分页将按钮“Older”链接到我的主页而不是我博客的第一页。分页似乎不知道 bgigurtsis 点 com/blog 是博客 post 的第一页,但我不确定如何解决这个问题。有什么想法吗?
谢谢!
在 ./_includes/pagination.html 它告诉分页在转到较新的帖子时导航到哪里。默认情况下,这设置为 / 当您的博客文章通常是这样时,它会起作用。我只是将其更改为 /blog.
完整的变化可以在这里看到: https://github.com/bgigurtsis/blog/commit/72f6210518551b8983a27ef2bf44bf67028b6b4f