【发布时间】:2021-05-22 10:11:41
【问题描述】:
问题:您可以点击“Older”进入旧博客的第二页,即https://www.bgigurtsis.com/blog/page2/。但是,在第二个页面上单击“更新”一次会将您带到主页https://www.bgigurtsis.com,而不是您刚刚在https://www.bgigurtsis.com/blog上的页面
我制作了这个 GIF 来说明这个问题:https://i.imgur.com/JN9qXoN.gif
我的设置 我使用的是托管在 AWS Amplify 上的 Jekyll 主题。通常对于这个主题,索引页面是所有博客文章所在的位置。我对此进行了更改,因此索引页面是一个“欢迎”帖子,其中包含指向博客的超链接。
要实现这一点:
- 我将 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
分页将“旧”按钮链接到我的主页,而不是我博客的第一页。似乎分页不知道 bgigurtsis dot com/blog 是博客文章的第一页,但我不知道如何解决这个问题。有什么想法吗?
谢谢!
【问题讨论】:
标签: pagination jekyll