Skip to content

Commit

Permalink
fix: use {.Page.Title} get the original categories/tags value.
Browse files Browse the repository at this point in the history
  • Loading branch information
ForrestSu committed Oct 31, 2019
1 parent 727bdcb commit a6c4709
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,11 @@ summaryLength = 140
busuanzi = true
```

#### 禁止分类的名称转为小写
#### 关于分类的名称转为小写的问题

我们在写文章的时候,会给文章进行分类,比如Golang,但是默认情况下,Hugo会把这个Golang转为小写,
这就我们一直用原始字符的造成困扰,为了解决这个问题,Hugo提供了`preserveTaxonomyNames`配置,把它设置为`true`就可以了保持原来分类的名字了。

```toml
## 保持分类的原始名字(false会做转小写处理)
preserveTaxonomyNames = true
```
`Hugo 0.55` 版本之前, 会有分类转成小写的问题,Hugo提供了`preserveTaxonomyNames`配置,把它设置为`true`就可以了保持原来分类的名字了。
`Hugo 0.55` 这个版本,[hugo 移除了 preserveTaxonomyNames 配置](https://gohugo.io/content-management/taxonomies/#example-removing-default-taxonomies)
模板已经默认获取 tag 和 categories 的原始字符用来展示, 大小写的问题已经优雅的解决了。

#### 禁止URL路径小写

Expand Down
6 changes: 2 additions & 4 deletions layouts/partials/categories.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<h3 class="widget-title">分类</h3>
<ul class="widget-list">
{{ range $name, $taxonomy := .Site.Taxonomies.categories }}
<li>
<a href="{{ "/categories/" | absLangURL }}{{ $name | urlize }}/">{{ $name }}({{len $taxonomy}})</a>
</li>
{{ range .Site.Taxonomies.categories }}
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }} ({{ .Count }})</a></li>
{{ end }}
</ul>
4 changes: 2 additions & 2 deletions layouts/partials/tags.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3 class="widget-title">标签</h3>
<div class="tagcloud">
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<a href="{{ "/tags/" | absLangURL }}{{ $name | urlize }}/">{{ $name }}</a>
{{ range .Site.Taxonomies.tags }}
<a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a>
{{ end }}
</div>

0 comments on commit a6c4709

Please sign in to comment.