问题描述
我在我的个人网站上使用 Hugo。我想在博客文章列表中添加分页。当我将分页器和默认模板添加到代码中时 页面生成但分页链接不可点击。
当我查看页面的来源时,我会看到指向下一页帖子的链接。当我点击其中一个分页器链接(在查看页面源代码中)时,我被带到下一页的源代码页面。
我正在使用版本
└─(17:09:51 on feature-create-default-post ✹ ✭)──> 雨果版 Hugo 静态站点生成器 v0.80.0/extended darwin/amd64 BuildDate:未知
这是我的博客文章的列表文件:
{{ define "main" }}
<h2>{{ .Title }}</h2>
<div class="posts-list">
{{ range .Paginator.Pages }}
<div class="post">
{{ partial "post_summary.html" . }}
<p></p>
<p></p>
</div>
{{ end }}
</div>
{{ template "_internal/pagination.html" . }}
{{ end }}
这里是 post_summary.html 部分
<article>
<header>
<div class="date">
{{ .PublishDate.Format "Jan. 2,2006" }}
</div>
<h1>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h1>
</header>
{{ .Summary }}
</article>
这里是 config.toml 文件
baseURL = "https://portfolio.novogrodsky.net/"
languageCode = "en-us"
title = "My New Hugo Site"
theme = "hugo-theme-console"
#adding pagination
paginate = 3
[params]
# Cutting off the page title to two chars for mobile (console-demo -> co)
titleCutting = true
twitter = "testing"
# Making sure my shortcodes can emmit html to the generated page.
[markup.goldmark.renderer]
unsafe= true
[[params.navlinks]]
name = "about/"
url = "about/"
[[params.navlinks]]
name = "posts/"
url = "posts/"
[[params.navlinks]]
name = "photos/"
url = "photos/"
[[params.navlinks]]
name = "DesignChallenge/"
url = "design-challenge/"
[permalinks]
posts = "posts/:year/:month/:slug"
我使用此选项在本地测试我的网站
hugo 服务器 --disableFastRender --buildDrafts
底部的分页链接不可点击。
但是生成页面的源代码有分页链接,它们确实将我带到下一页帖子的源代码。
<!DOCTYPE html>
<html lang="en-us">
<head><script src="/livereload.js?mindelay=10&v=2&port=1313&path=livereload" data-no-instant defer></script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My New Hugo Site/posts/</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="all,follow">
<meta name="googlebot" content="index,follow,snippet,archive">
<link rel="stylesheet" href="http://localhost:1313/hugo-theme-console/css/terminal-0.7.1.min.css">
<link rel="stylesheet" href="http://localhost:1313/hugo-theme-console/css/animate-3.7.2.min.css">
<link rel="stylesheet" href="http://localhost:1313/hugo-theme-console/css/console.css">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link href="http://localhost:1313/posts/index.xml" rel="alternate" type="application/rss+xml" title="My New Hugo Site" />
<meta property="og:title" content="Posts" />
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://localhost:1313/posts/" />
<meta name="twitter:title" content="Posts"/>
<meta name="twitter:description" content=""/>
</head>
<body class="terminal">
<div class="container">
<div class="terminal-nav">
<header class="terminal-logo">
<div class="logo terminal-prompt">
<a href="http://localhost:1313/" class="no-style site-name">My New Hugo Site</a>:~# <a href='http://localhost:1313/posts'>posts</a>/</div></header>
<nav class="terminal-menu">
<ul vocab="https://schema.org/" typeof="BreadcrumbList">
<li><a href="http://localhost:1313/about/" typeof="ListItem">about/</a></li>
<li><a href="http://localhost:1313/posts/" typeof="ListItem">posts/</a></li>
<li><a href="http://localhost:1313/photos/" typeof="ListItem">photos/</a></li>
<li><a href="http://localhost:1313/design-challenge/" typeof="ListItem">DesignChallenge/</a></li>
</ul>
</nav>
</div>
</div>
<div class="container animated zoomIn fast">
<h2>Posts</h2>
<div class="posts-list">
<div class="post">
<article>
<header>
<div class="date">
Jul. 7,2020
</div>
<h1>
<a href="/posts/2020/07/status-of-design-challenge/">Status of Design Challenge</a>
</h1>
</header>
Hello,I am just giving an update on the design challenge.
It is going well. The ability to publish this site quickly has really helped making the design challenge a reality. I have learned a lot about CSS,HTML5,and Markdown. They work well together.
I look forward to continuing this challenge.
</article>
<p></p>
<p></p>
</div>
<div class="post">
<article>
<header>
<div class="date">
Jun. 14,2020
</div>
<h1>
<a href="/posts/2020/06/content-for-desing-challenge/">Content for Desing Challenge</a>
</h1>
</header>
Summary (h1 header) This is my first experiment with CSS and design. I generated this Ipsum Loren from Lorem Markdownum. The links do not go to live pages.
O penates includit sunt Graias contemptus rigidoque (h1 header) Tasks
Bacon ipsum dolor amet shank Pig prosciutto Flank ground round First Term This is the definition of the first term. Second Term This is one definition of the second term.
</article>
<p></p>
<p></p>
</div>
<div class="post">
<article>
<header>
<div class="date">
Jun. 14,2020
</div>
<h1>
<a href="/posts/2020/06/starting-design-work/">Starting Design Work</a>
</h1>
</header>
My first 100 Day Challenge
I was at the Digital Design Days recently and I was inspired by GMunk’s talk. He talked about a 100 day chanllenge. The idea is do something for 100 days consistently. It does not have to be a big thing,just something. GMunk decided to take a photo each day for 100 days.
I have decided to design a page each day for 100 days. I will be learning a lot about CSS and Javascript.
</article>
<p></p>
<p></p>
</div>
</div>
<ul class="pagination">
<li class="page-item">
<a href="/posts/" class="page-link" aria-label="First"><span aria-hidden="true">««</span></a>
</li>
<li class="page-item disabled">
<a class="page-link" aria-label="Previous"><span aria-hidden="true">«</span></a>
</li>
<li class="page-item active">
<a class="page-link" href="/posts/">1</a>
</li>
<li class="page-item">
<a class="page-link" href="/posts/page/2/">2</a>
</li>
<li class="page-item">
<a href="/posts/page/2/" class="page-link" aria-label="Next"><span aria-hidden="true">»</span></a>
</li>
<li class="page-item">
<a href="/posts/page/2/" class="page-link" aria-label="Last"><span aria-hidden="true">»»</span></a>
</li>
</ul>
<div class="footer">
Powered by <a href="https://gohugo.io/">Hugo</a> with
<a href="https://github.com/mrmierzejewski/hugo-theme-console/">Console Theme</a>.
</div>
</div>
</body>
</html>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)