Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Categories and tags are not displayed. #9

Closed
guyueshui opened this issue Mar 15, 2020 · 11 comments
Closed

Categories and tags are not displayed. #9

guyueshui opened this issue Mar 15, 2020 · 11 comments

Comments

@guyueshui
Copy link

你好,我非常喜欢这个主题,感谢你做的移植工作。但是我在配置过程中遇到一个问题,就是分类页和标签页没有东西显示。我看了你的文档,分类确实只用了一个值,没有用括号括起来,但还是空白,请问如何解决?
screenshot-20200316-00-16-33

@AmazingRise
Copy link
Owner

暂时无法复现出这个问题。
建议检查一下:

  1. 你是否正确配置了Taxonomies
  2. 另外请劳烦您提供一下某篇博文的 Frontmatter 区。(一篇就够

@guyueshui
Copy link
Author

暂时无法复现出这个问题。
建议检查一下:

  1. 你是否正确配置了Taxonomies
  2. 另外请劳烦您提供一下某篇博文的 Frontmatter 区。(一篇就够

你好,我的配置文件如下:

# hugo site config
baseurl = "https://guyueshui.github.io/yukynn"
languageCode = "zh-cn"
defaultContentLanguage = "zh-cn"
title = "Yukynnの窝"
theme = "diary"

# copyright = ""

# googleAnalytics = ""

# disqusShortname = ""

# enableRobotsTXT = true

# baseURL = "https://guyueshui.github.io/yukynn"
# preserveTaxonomyNames = true
enableRobotsTXT = true
enableEmoji = true
footnoteReturnLinkContents = ""
hasCJKLanguage = true


[params]
  subtitle="子在川上曰,逝者如斯夫。"
  # background = "#f8f8f5"

  author = "Yukynn"
  description = "Yukynn's showcase"

  siteStartYear = 2020

  # paginate of archives, tags and categories             # 归档、标签、分类每页显示的文章数目,建议修改为一个较大的值
  # archivePaginate = 15

  # The date format to use; for a list of valid formats, see https://gohugo.io/functions/format/
  dateFormatToUse = "January 2, 2006"


[blackfriday]
  # translate new line into linebreaks
  # extensions = ["hardLineBreak"]
  smartypants = false


[taxonomies]
  tag = "tags"
  category = "categories"

[[menu.main]]
  url = "/posts"
  name = "文章"
  weight = 1
[[menu.main]]
  url = "/categories"
  name = "分类"
  weight = 2
[[menu.main]]
  url = "/tags"
  name = "标签"
  weight = 3
[[menu.main]]
  url = "/about"
  name = "关于"
  weight = 4
[[menu.main]]
  url = "/index.xml"
  name = "订阅"
  weight = 5

昨天刚开始建站,从我的博客里拷了几篇文章来,frontmatter如下:

---
title: Hello World
date: 2020-03-11T20:50:39+08:00
lastmod: 2020-03-11T20:50:39+08:00
categories: "cat1"
tags: ["tag1", "tag2"]
featured_image: "/artworks/bilibilier.jpg"
description: 你好世界,愿这里成为你的一片净土。
---

上面这个是hello-world, 我也从我之前博客里复制了几篇过来,frontmatter可能不一样,但仅仅只是date format的区别。

@AmazingRise
Copy link
Owner

我今天尝试了一下复现这个 bug,但是并没有成功。
图片
图片
图片

@AmazingRise
Copy link
Owner

我的复现步骤:

  1. 将博客目录重新复制了一份,清除contents下的内容
  2. posts下新建一个空白的.md文件,将你的Frontmatter复制过来。(为方便起见 我去掉了和此问题无关紧要的featured_image选项)并且随手粘贴了一点其他内容
  3. 替换掉config.toml

你可以再检查一下,重新启动hugo server,看看结果是否正常。
因为hugo server默认处于快速渲染模式下,更改博文的分类,hugo server默认并不会实时更新。

@guyueshui
Copy link
Author

佛了,我复现了一下,

hugo new site test
cd test
cd themes
git clone https://github.com/AmazingRise/hugo-theme-diary.git diary
cd ..
mv themes/diary/exampleSite/config.toml ./config.toml
cp /path/to/hello-world.md ./content/posts/
cat ./content/hello-world.md
---
title: Hello World
date: 2020-03-11T20:50:39+08:00
lastmod: 2020-03-11T20:50:39+08:00
categories: "cat1"
tags: ["tag1", "tag2"]
description: 你好世界,愿这里成为你的一片净土。

---


balabala....

然后还是有这个问题:
image
image
难道是看机器的吗orz..., 麻烦你了,你还是找不到原因的话就算了吧,感谢!

@AmazingRise
Copy link
Owner

图片

  1. 你的 Hugo 版本是多少?(hugo version)
  2. 打开 F12,看看控制台里面是否有报错?
  3. 另外如果你换一个主题,这个现象是否能够复现?

@guyueshui
Copy link
Author

$ hugo version
Hugo Static Site Generator v0.65.0/extended linux/amd64 BuildDate: unknown

image

以下是even主题的截图:
image
category和tag页面正常。

@AmazingRise
Copy link
Owner

佛了,我复现了一下,

hugo new site test
cd test
cd themes
git clone https://github.com/AmazingRise/hugo-theme-diary.git diary
cd ..
mv themes/diary/exampleSite/config.toml ./config.toml
cp /path/to/hello-world.md ./content/posts/
cat ./content/hello-world.md
---
title: Hello World
date: 2020-03-11T20:50:39+08:00
lastmod: 2020-03-11T20:50:39+08:00
categories: "cat1"
tags: ["tag1", "tag2"]
description: 你好世界,愿这里成为你的一片净土。

---


balabala....

按照本楼层的配置,尝试用 hugo 命令生成网站,看 /public/categories目录下是否有文件夹?
或者说用hugo server,看是否能访问 http://localhost:1313/categories/cat1/

如果上面的回答都是 Yes,那么你尝试一下修改这行代码
{{ range .Paginator.Pages }} 改为 {{ range .Pages }}
看看问题是否存在

@guyueshui
Copy link
Author

Yes, and 有了!非常感谢!什么原因呢?

@AmazingRise
Copy link
Owner

我以前在用 0.65 的时候没有这个问题。
这个地方是对所有的分类进行遍历,如果套了个 Paginator 就是要求分页。
所以去掉 Paginator 的后果就是,如果你有 1w 个分类,都会显示在一页上,不会分页。

我查了一下官方论坛上的说法:链接
这种用法是允许的,但是搞不明白为什么在你的环境下运行不通,貌似之前也没有别人反馈过这个问题。
我觉得这个问题:Pagination with terms doesn't work in my environment 可以反馈到 Hugo 那边。

@AmazingRise AmazingRise pinned this issue Mar 23, 2020
@AmazingRise
Copy link
Owner

I have pinned this issue.
If someone else can reproduce the bug, please re-open this issue.

@AmazingRise AmazingRise changed the title 分类和标签无显示 Categories and tags are not displayed. Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants