fix: eliminate deprecation warnings with hugo version 0.156.0 (#702)

* Fix deprecation warning with latest hugo version 0.156.0

* fix: use `hugo.Data` to replace the discarded `.Site.Data`

* chore(hugo): update Hugo version requirements to 0.156.0

---------

Co-authored-by: Cell <1024@lruihao.cn>
This commit is contained in:
Andreas Deininger
2026-02-27 08:46:31 +01:00
committed by GitHub
parent 581d8373bf
commit 175cf888d5
15 changed files with 20 additions and 20 deletions
+3 -3
View File
@@ -6,7 +6,7 @@
FixIt 是一个面向 Hugo 静态网站生成器的现代化、响应式主题。项目基于以下技术栈:
- **Hugo**: 静态网站生成器(≥ 0.147.7
- **Hugo**: 静态网站生成器(≥ 0.156.0
- **SCSS**: CSS 预处理器,用于样式开发
- **JavaScript**: ES6+ 标准,用于前端交互功能
- **Go Templates**: Hugo 模板引擎
@@ -184,7 +184,7 @@ class FixIt {
4. **循环遍历**: 合理使用 range
```go-html-template
{{- range $index, $value := .Site.Languages -}}
{{- range $index, $value := .Pages -}}
<!-- 处理逻辑 -->
{{- end -}}
```
@@ -211,7 +211,7 @@ class FixIt {
1. **前置要求**:
- Node.js (≥ 20.0.0)
- Hugo Extended (≥ 0.147.7)
- Hugo Extended (≥ 0.156.0)
- pnpm (包管理器)
2. **开发命令**:
+1 -1
View File
@@ -7,7 +7,7 @@ Make sure that you follow [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) while contrib
Before you start contributing, make sure you have the following tools installed:
- **Node.js** (>= 20.0.0) - Required for package management and build tools
- **Hugo Extended** (>= 0.147.7) - The static site generator
- **Hugo Extended** (>= 0.156.0) - The static site generator
- **pnpm** - Package manager (recommended)
You can check your installed versions:
+1 -1
View File
@@ -26,7 +26,7 @@
[![Build](https://img.shields.io/github/deployments/hugo-fixit/FixIt/Production?style=flat&label=Build&logo=vercel)](https://demo.fixit.lruihao.cn/)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat&label=Release&logo=github&include_prereleases)](https://github.com/hugo-fixit/FixIt/releases)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.147.7-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.156.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat&label=License)](/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/hugo-fixit/FixIt?style=social)](https://github.com/hugo-fixit/FixIt)
[![Gitee star of FixIt](https://gitee.com/lruihao/FixIt/badge/star.svg)](https://gitee.com/lruihao/FixIt/stargazers)
+1 -1
View File
@@ -26,7 +26,7 @@
[![Build](https://img.shields.io/github/deployments/hugo-fixit/FixIt/Production?style=flat&label=Build&logo=vercel)](https://demo.fixit.lruihao.cn/)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat&label=Release&logo=github&include_prereleases)](https://github.com/hugo-fixit/FixIt/releases)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.147.7-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.156.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat&label=License)](/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/hugo-fixit/FixIt?style=social)](https://github.com/hugo-fixit/FixIt)
[![Gitee star of FixIt](https://gitee.com/lruihao/FixIt/badge/star.svg)](https://gitee.com/lruihao/FixIt/stargazers)
+1 -1
View File
@@ -6,7 +6,7 @@ Only the latest version receives active maintenance and security updates:
| Version | Hugo Version | LoveIt Compat | Supported |
| :-----: | :---------------: | :----------------: | :----------------: |
| 0.4.x | >= 0.147.7 | N/A | :white_check_mark: |
| 0.4.x | 0.147.7 ~ latest | N/A | :white_check_mark: |
| 0.3.x | 0.112.0 ~ 0.146.0 | N/A | :x: |
| 0.2.x | 0.62.0 ~ 0.110.0 | :white_check_mark: | :x: |
| 0.1.x | Unknown | :white_check_mark: | :x: |
@@ -115,7 +115,7 @@ Trying the file not found case (should fallback to next mode):
{{< file-tree file="data/nonexistent.yaml" data="example" />}}
### Site data
### Hugo data
#### Basic usage
+1 -1
View File
@@ -171,7 +171,7 @@ weight = 80
[module.hugoVersion]
extended = true
min = "0.147.7"
min = "0.156.0"
# -------------------------------------------------------------------------------------
# Markup Configuration
+3 -3
View File
@@ -1,4 +1,4 @@
{{- $buildDrafts := .Site.BuildDrafts -}}
{{- $buildDrafts := .Page.Draft -}}
{{- $relLangURL := relLangURL "" -}}
{{- /* Desktop header */ -}}
@@ -118,7 +118,7 @@
</span>
<ul class="sub-menu">
{{- if (eq .Kind "404") -}}
{{- range .Sites -}}
{{- range hugo.Sites -}}
{{- if ne . $.Site -}}
{{- $link := printf "%v/404.html" .LanguagePrefix -}}
<li class="menu-item">
@@ -292,7 +292,7 @@
</span>
<select id="language-select" class="language-select" onchange="location = this.value;">
{{- if eq .Kind "404" -}}
{{- range .Sites -}}
{{- range hugo.Sites -}}
{{- $link := printf "%v/404.html" .LanguagePrefix -}}
<option value="{{ $link }}"{{ if eq . $.Site }} selected disabled{{ end }}>
{{- .Language.LanguageName -}}
+1 -1
View File
@@ -25,7 +25,7 @@
{{- if ne .Site.Params.dev.enable true -}}
{{- .Site.Store.Set "devOpts" dict -}}
{{- end -}}
{{- if eq .Site .Sites.Default -}}
{{- if eq .Site hugo.Sites.Default -}}
{{- warnf "FixIt %v\n%v\n\n" (hugo.Store.Get "version") (T "init.devEnvWarn") -}}
{{- end -}}
{{- end -}}
@@ -10,7 +10,7 @@
{{- end -}}
{{- /* FixIt theme version detection */ -}}
{{- if eq .Site .Sites.Default -}}
{{- if eq .Site hugo.Sites.Default -}}
{{- if not .Site.Params.version -}}
{{- errorf "FixIt %v\n%v\n\n" $version (T "init.configurationError") -}}
{{- else if gt "0.2.0" (strings.TrimPrefix "v" .Site.Params.version) -}}
+1 -1
View File
@@ -24,7 +24,7 @@
<template data-fmt="js" data-async="{{ $async }}">{{ $content | safeJS }}</template>
{{- else -}}
{{ with $data }}
{{- $content = index site.Data.echarts (printf "%v.%v" . page.Language) | default (index site.Data.echarts .) -}}
{{- $content = index hugo.Data.echarts (printf "%v.%v" . page.Language) | default (index hugo.Data.echarts .) -}}
{{- if not $content -}}
{{- warnf "ECharts: data not found, please ensure the data file \"data/echarts/%s.{json|yml|yaml|toml}\" exists." . -}}
{{- end -}}
+1 -1
View File
@@ -10,7 +10,7 @@
{{- /* Get Timeline events */ -}}
{{- $content := .Inner -}}
{{ with $data }}
{{- $content = index site.Data.timeline (printf "%v.%v" . page.Language) | default (index site.Data.timeline .) -}}
{{- $content = index hugo.Data.timeline (printf "%v.%v" . page.Language) | default (index hugo.Data.timeline .) -}}
{{- if not $content -}}
{{- warnf "Timeline: data not found, please ensure the data file \"data/timeline/%s.{json|yml|yaml|toml}\" exists." . -}}
{{- end -}}
+2 -2
View File
@@ -89,9 +89,9 @@
{{- end -}}
{{- end -}}
{{- /* Site Data: load from data/filetree/ */ -}}
{{- /* Hugo Data: load from data/filetree/ */ -}}
{{- if $dataName | and (not $treeData) -}}
{{- with index .Site.Data.filetree (printf "%v.%v" $dataName .Page.Language) | default (index .Site.Data.filetree $dataName) -}}
{{- with index hugo.Data.filetree (printf "%v.%v" $dataName .Page.Language) | default (index hugo.Data.filetree $dataName) -}}
{{- $treeData = . -}}
{{- else -}}
{{- $exts := delimit (apply $supportExts "trim" "." "\\.") "|" -}}
+1 -1
View File
@@ -16,7 +16,7 @@
{{- /* Friend links */ -}}
<script src="//at.alicdn.com/t/font_578712_g26jo2kbzd5qm2t9.js" async defer></script>
<div class="friend-links">
{{ range $index, $friend := .Site.Data.friends }}
{{ range $index, $friend := hugo.Data.friends }}
<a class="friend-link" title="{{ $friend.description | safeHTML }}" href="{{ $friend.url | safeURL }}" rel="external noopener" target="_blank">
{{ if $friend.avatar }}
{{- dict "Src" $friend.avatar "Alt" $friend.nickname "Title" $friend.description "Class" "friend-avatar" | partial "plugin/image.html" -}}
+1 -1
View File
@@ -7,7 +7,7 @@ licenselink = "https://github.com/hugo-fixit/FixIt/blob/main/LICENSE"
description = "A Clean, Elegant but Advanced Hugo Theme for Hugo."
homepage = "https://github.com/hugo-fixit/FixIt"
demosite = "https://fixit.lruihao.cn"
min_version = "0.147.7"
min_version = "0.156.0"
tags = [
"blog",
"clean",