📝 Docs(content): update "theme-documentation-basics" (#37)

This commit is contained in:
Cell
2022-01-24 17:11:59 +08:00
parent 47bcdf610c
commit 12e2768851
3 changed files with 263 additions and 185 deletions
-4
View File
@@ -1016,10 +1016,6 @@ enableEmoji = true
# Privacy config (https://gohugo.io/about/hugo-and-gdpr/)
# 隐私信息配置 (https://gohugo.io/about/hugo-and-gdpr/)
[privacy]
# privacy of the Google Analytics (replaced by params.analytics.google)
# Google Analytics 相关隐私 (被 params.analytics.google 替代)
[privacy.googleAnalytics]
# ...
[privacy.twitter]
enableDNT = true
[privacy.youtube]
@@ -2,11 +2,11 @@
weight: 1
title: "Theme Documentation - Basics"
date: 2020-03-06T21:29:01+08:00
lastmod: 2020-03-06T21:29:01+08:00
lastmod: 2022-01-12T17:09:01+08:00
draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Discover what the Hugo - LoveIt theme is all about and the core-concepts behind it."
author: "Lruihao"
authorLink: "https://lruihao.cn"
description: "Discover what the Hugo - FixIt theme is all about and the core-concepts behind it."
resources:
- name: "featured-image"
src: "featured-image.jpg"
@@ -20,7 +20,7 @@ toc:
auto: false
---
Discover what the Hugo - **LoveIt** theme is all about and the core-concepts behind it.
Discover what the Hugo - **FixIt** theme is all about and the core-concepts behind it.
<!--more-->
@@ -53,26 +53,26 @@ cd my_website
### 2.2 Install the Theme
The **LoveIt** themes repository is: [https://github.com/dillonzq/LoveIt](https://github.com/dillonzq/LoveIt).
The **FixIt** themes repository is: <https://github.com/Lruihao/FixIt>.
You can download the [latest release :(far fa-file-archive fa-fw): .zip file](https://github.com/dillonzq/LoveIt/releases) of the theme and extract it in the `themes` directory.
You can download the [latest release :(far fa-file-archive fa-fw): .zip file](https://github.com/Lruihao/FixIt/releases) of the theme and extract it in the `themes` directory.
Alternatively, clone this repository to the `themes` directory:
```bash
git clone https://github.com/dillonzq/LoveIt.git themes/LoveIt
git clone https://github.com/Lruihao/FixIt.git themes/FixIt
```
Or, create an empty git repository and make this repository a submodule of your site directory:
```bash
git init
git submodule add https://github.com/dillonzq/LoveIt.git themes/LoveIt
git submodule add https://github.com/Lruihao/FixIt.git themes/FixIt
```
### 2.3 Basic Configuration {#basic-configuration}
The following is a basic configuration for the LoveIt theme:
The following is a basic configuration for the FixIt theme:
```toml
baseURL = "http://example.org/"
@@ -83,10 +83,10 @@ languageCode = "en"
title = "My New Hugo Site"
# Change the default theme to be use when building the site with Hugo
theme = "LoveIt"
theme = "FixIt"
[params]
# LoveIt theme version
# FixIt theme version
version = "0.2.X"
[menu]
@@ -188,13 +188,13 @@ Alternatively, you can use [AWS Amplify](https://gohugo.io/hosting-and-deploymen
### 3.1 Site Configuration {#site-configuration}
In addition to [Hugo global configuration](https://gohugo.io/overview/configuration/) and [menu configuration](#basic-configuration), **LoveIt** lets you define the following parameters in your site configuration (here is a `config.toml`, whose values are default).
In addition to [Hugo global configuration](https://gohugo.io/overview/configuration/) and [menu configuration](#basic-configuration), **FixIt** lets you define the following parameters in your site configuration (here is a `config.toml`, whose values are default).
Please open the code block below to view the complete sample configuration :(far fa-hand-point-down fa-fw)::
```toml
[params]
# {{< version 0.2.0 changed >}} LoveIt theme version
# {{< version 0.2.0 changed >}} FixIt theme version
version = "0.2.X"
# site description
description = "This is My New Hugo Site"
@@ -211,21 +211,25 @@ Please open the code block below to view the complete sample configuration :(far
dateFormat = "2006-01-02"
# website images for Open Graph and Twitter Cards
images = ["/logo.png"]
# {{< version 0.2.12 >}} enable PWA
enablePWA = true
# {{< version 0.2.0 >}} App icon config
[params.app]
# optional site title override for the app when added to an iOS home screen or Android launcher
title = "LoveIt"
title = "FixIt"
# whether to omit favicon resource links
noFavicon = false
# modern SVG favicon to use in place of older style .png and .ico files
svgFavicon = ""
# Android browser theme color
themeColor = "#ffffff"
# Safari mask icon color
iconColor = "#5bbad5"
# Windows v8-10 tile color
tileColor = "#da532c"
# {{< version 0.2.12 changed >}} Android browser theme color
[params.app.themeColor]
light = "#ffffff"
dark = "#252627"
# {{< version 0.2.0 >}} Search config
[params.search]
@@ -330,9 +334,6 @@ Please open the code block below to view the complete sample configuration :(far
enable = true
# special amount of posts in each home posts page
paginate = 6
# {{< version 0.2.0 deleted >}} replaced with hiddenFromHomePage in params.page
# default behavior when you don't set "hiddenFromHomePage" in front matter
defaultHiddenFromHomePage = false
# Social config about the author
[params.social]
@@ -417,6 +418,8 @@ Please open the code block below to view the complete sample configuration :(far
fraction = true
# {{< version 0.2.0 >}} whether to enable the fontawesome extended syntax
fontawesome = true
# license info (HTML format is supported)
license = '<a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
# whether to show link to Raw Markdown content of the content
linkToMarkdown = true
# {{< version 0.2.4 >}} whether to show the full text content in RSS
@@ -429,7 +432,7 @@ Please open the code block below to view the complete sample configuration :(far
keepStatic = true
# whether to make the table of the contents in the sidebar automatically collapsed
auto = true
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} mathematical formulas
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} mathematical formulas (https://katex.org)
[params.page.math]
enable = true
# default block delimiter is $$ ... $$ and \\[ ... \\]
@@ -448,7 +451,7 @@ Please open the code block below to view the complete sample configuration :(far
copy = true
# the maximum number of lines of displayed code by default
maxShownLines = 10
# {{< version 0.2.0 >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" "Mapbox GL JS" >}} config
# {{< version 0.2.0 >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" "Mapbox GL JS" >}} config (https://docs.mapbox.com/mapbox-gl-js)
[params.page.mapbox]
# access token of Mapbox GL JS
accessToken = ""
@@ -497,13 +500,13 @@ Please open the code block below to view the complete sample configuration :(far
# {{< version 0.2.0 changed >}} Comment config
[params.page.comment]
enable = true
# {{< link "https://disqus.com/" Disqus >}} comment config
# {{< link "https://disqus.com/" Disqus >}} comment config (https://disqus.com)
[params.page.comment.disqus]
# {{< version 0.1.1 >}}
enable = false
# Disqus shortname to use Disqus in posts
shortname = ""
# {{< link "https://github.com/gitalk/gitalk" Gitalk >}} comment config
# {{< link "https://github.com/gitalk/gitalk" Gitalk >}} comment config (https://github.com/gitalk/gitalk)
[params.page.comment.gitalk]
# {{< version 0.1.1 >}}
enable = false
@@ -511,7 +514,7 @@ Please open the code block below to view the complete sample configuration :(far
repo = ""
clientId = ""
clientSecret = ""
# {{< link "https://github.com/xCss/Valine" Valine >}} comment config
# {{< link "https://github.com/xCss/Valine" Valine >}} comment config (https://github.com/xCss/Valine)
[params.page.comment.valine]
enable = false
appId = ""
@@ -528,18 +531,18 @@ Please open the code block below to view the complete sample configuration :(far
serverURLs = ""
# {{< version 0.2.6 >}} emoji data file name, default is "google.yml"
# ("apple.yml", "google.yml", "facebook.yml", "twitter.yml")
# located in "themes/LoveIt/assets/data/emoji/" directory
# located in "themes/FixIt/assets/data/emoji/" directory
# you can store your own data files in the same path under your project:
# "assets/data/emoji/"
emoji = ""
# {{< link "https://developers.facebook.com/docs/plugins/comments" "Facebook comment" >}} config
# {{< link "https://developers.facebook.com/docs/plugins/comments" "Facebook comment" >}} config (https://developers.facebook.com/docs/plugins/comments)
[params.page.comment.facebook]
enable = false
width = "100%"
numPosts = 10
appId = ""
languageCode = ""
# {{< version 0.2.0 >}} {{< link "https://comments.app/" "Telegram comments" >}} config
# {{< version 0.2.0 >}} {{< link "https://comments.app/" "Telegram comments" >}} config (https://comments.app)
[params.page.comment.telegram]
enable = false
siteID = ""
@@ -549,10 +552,10 @@ Please open the code block below to view the complete sample configuration :(far
colorful = true
dislikes = false
outlined = false
# {{< version 0.2.0 >}} {{< link "https://commento.io/" "Commento" >}} comment config
# {{< version 0.2.0 >}} {{< link "https://commento.io/" "Commento" >}} comment config (https://commento.io)
[params.page.comment.commento]
enable = false
# {{< version 0.2.5 >}} {{< link "https://utteranc.es/" "Utterances" >}} comment config
# {{< version 0.2.5 >}} {{< link "https://utteranc.es/" "Utterances" >}} comment config (https://utteranc.es)
[params.page.comment.utterances]
enable = false
# owner/repo
@@ -593,6 +596,37 @@ Please open the code block below to view the complete sample configuration :(far
# cursor duration after typing finishing (measured in milliseconds, "-1" means unlimited)
duration = -1
# {{< version 0.2.12 >}} Watermark config
# Detail config see https://github.com/Lruihao/watermark#readme
[params.watermark]
enable = false
# watermark's text (HTML format is supported)
content = ''
# watermark's transparency
opacity = 0.1
# parent of watermark's container
appendTo = '.wrapper>.main'
# watermark's width. unit: px
width = 150
# watermark's height. unit: px
height = 20
# row spacing of watermarks. unit: px
rowSpacing = 60
# col spacing of watermarks. unit: px
colSpacing = 30
# watermark's tangent angle. unit: deg
rotate = 15
# watermark's fontSize. unit: rem
fontSize = 0.85
# {{< version 0.2.12 >}} Busuanzi count
[params.ibruce]
enable = true
# Enable in post meta
enablePost = false
# Site creation time e.g. '2019-02-03T19:30:34+08:00'
siteTime = ''
# Site verification code config for Google/Bing/Yandex/Pinterest/Baidu
[params.verification]
google = ""
@@ -635,7 +669,7 @@ Please open the code block below to view the complete sample configuration :(far
[params.cdn]
# CDN data file name, disabled by default
# ("jsdelivr.yml")
# located in "themes/LoveIt/assets/data/cdn/" directory
# located in "themes/FixIt/assets/data/cdn/" directory
# you can store your own data files in the same path under your project:
# "assets/data/cdn/"
data = ""
@@ -649,7 +683,7 @@ Please open the code block below to view the complete sample configuration :(far
# Markup related config in Hugo
[markup]
# {{< link "https://gohugo.io/content-management/syntax-highlighting" "Syntax Highlighting" >}}
# {{< link "https://gohugo.io/content-management/syntax-highlighting" "Syntax Highlighting" >}} (https://gohugo.io/content-management/syntax-highlighting)
[markup.highlight]
codeFences = true
guessSyntax = true
@@ -688,16 +722,13 @@ Please open the code block below to view the complete sample configuration :(far
filename = "sitemap.xml"
priority = 0.5
# {{< link "https://gohugo.io/content-management/urls#permalinks" "Permalinks config" >}}
# {{< link "https://gohugo.io/content-management/urls#permalinks" "Permalinks config" >}} (https://gohugo.io/content-management/urls#permalinks)
[Permalinks]
# posts = ":year/:month/:filename"
posts = ":filename"
# {{< link "https://gohugo.io/about/hugo-and-gdpr/" "Privacy config" >}}
# {{< link "https://gohugo.io/about/hugo-and-gdpr/" "Privacy config" >}} (https://gohugo.io/about/hugo-and-gdpr/)
[privacy]
# {{< version 0.2.0 deleted >}} privacy of the Google Analytics (replaced by params.analytics.google)
[privacy.googleAnalytics]
# ...
[privacy.twitter]
enableDNT = true
[privacy.youtube]
@@ -747,7 +778,7 @@ You could enable these features with `hugo serve -e production`.
data = ""
````
The default CDN data file is located in `themes/LoveIt/assets/data/cdn/` directory.
The default CDN data file is located in `themes/FixIt/assets/data/cdn/` directory.
You can store your own data file in the same path under your project: `assets/data/cdn/`.
{{< /admonition >}}
@@ -778,7 +809,7 @@ Or You can set more options through a dict:
title = "Mastodon"
```
The default data of all supported social links is located in `themes/LoveIt/assets/data/social.yaml`,
The default data of all supported social links is located in `themes/FixIt/assets/data/social.yaml`,
which is you can refer to.
{{< /admonition >}}
@@ -807,11 +838,11 @@ Customize `browserconfig.xml` and `site.webmanifest` to set theme-color and back
Hugo **extended** version is necessary for the style customization.
{{< /admonition >}}
**LoveIt** theme has been built to be as configurable as possible by defining custom `.scss` style files.
**FixIt** theme has been built to be as configurable as possible by defining custom `.scss` style files.
The directory including the custom `.scss` style files is `assets/css` relative to **your project root directory**.
In `assets/css/_override.scss`, you can override the variables in `themes/LoveIt/assets/css/_variables.scss` to customize the style.
In `assets/css/_override.scss`, you can override the variables in `themes/FixIt/assets/css/_variables.scss` to customize the style.
Here is a example:
@@ -824,7 +855,7 @@ In `assets/css/_custom.scss`, you can add some css style code to customize the s
## 4 Multilingual and i18n
**LoveIt** theme is fully compatible with Hugo multilingual mode, which provides in-browser language switching.
**FixIt** theme is fully compatible with Hugo multilingual mode, which provides in-browser language switching.
![Language Switch](language-switch.gif "Language Switch")
@@ -842,11 +873,11 @@ In `assets/css/_custom.scss`, you can add some css style code to customize the s
| Italian | `it` | `it` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Spanish | `es` | `es` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| German | `de` | `de` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| German | `de` | `de` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Serbian | `sr` | `sr` | :(far fa-square fa-fw): | :(far fa-square fa-fw): |
| Russian | `ru` | `ru` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Romanian | `ro` | `ro` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Vietnamese | `vi` | `vi` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| Traditional Chinese | `zh-tw` | `zh-TW` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
### 4.2 Basic Configuration
@@ -973,15 +1004,15 @@ Use [Front Matter parameter](https://gohugo.io/content-management/multilingual#t
Translations strings are used for common default values used in the theme. Translations are available in [some languages](#language-compatibility), but you may use another language or want to override default values.
To override these values, create a new file in your local i18n folder `i18n/<languageCode>.toml` and inspire yourself from `themes/LoveIt/i18n/en.toml`.
To override these values, create a new file in your local i18n folder `i18n/<languageCode>.toml` and inspire yourself from `themes/FixIt/i18n/en.toml`.
By the way, as these translations could be used by other people, please take the time to propose a translation by [:(fas fa-code-branch fa-fw): making a PR](https://github.com/dillonzq/LoveIt/pulls) to the theme!
By the way, as these translations could be used by other people, please take the time to propose a translation by [:(fas fa-code-branch fa-fw): making a PR](https://github.com/Lruihao/FixIt/pulls) to the theme!
## 5 Search
{{< version 0.2.0 >}}
Based on [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/), searching is supported in **LoveIt** theme.
Based on [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/), searching is supported in **FixIt** theme.
### 5.1 Output Configuration
@@ -1039,3 +1070,9 @@ You could upload the `index.json` files by browsers but a CLI tool may be better
To be compatible with Hugo multilingual mode,
you need to upload different `index.json` for each language to the different index of algolia, such as `zh-cn/index.json` or `fr/index.json`...
{{< /admonition >}}
---
{{< admonition quote "Thanks" >}}
_Thanks to the original author [Dillon](https://dillonzq.com) for preparing and revising the content before version `v0.2.10` in this documentation._
{{< /admonition >}}
@@ -2,11 +2,11 @@
weight: 1
title: "主题文档 - 基本概念"
date: 2020-03-06T21:40:32+08:00
lastmod: 2020-03-06T21:40:32+08:00
lastmod: 2022-01-24T15:21:32+08:00
draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "探索 Hugo - LoveIt 主题的全部内容和背后的核心概念."
author: "Lruihao"
authorLink: "https://lruihao.cn"
description: "探索 Hugo - FixIt 主题的全部内容和背后的核心概念"
resources:
- name: "featured-image"
src: "featured-image.jpg"
@@ -20,31 +20,31 @@ toc:
auto: false
---
探索 Hugo - **LoveIt** 主题的全部内容和背后的核心概念.
探索 Hugo - **FixIt** 主题的全部内容和背后的核心概念
<!--more-->
## 1 准备
由于 Hugo 提供的便利性, [Hugo](https://gohugo.io/) 本身是这个主题唯一的依赖.
由于 Hugo 提供的便利性[Hugo](https://gohugo.io/) 本身是这个主题唯一的依赖
直接安装满足你操作系统 (**Windows**, **Linux**, **macOS**) 的最新版本 [:(far fa-file-archive fa-fw): Hugo (> 0.62.0)](https://gohugo.io/getting-started/installing/).
{{< admonition note "为什么不支持早期版本的 Hugo?" >}}
由于 [Markdown 渲染钩子函数](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks) 在 [Hugo 圣诞节版本](https://gohugo.io/news/0.62.0-relnotes/) 中被引入, 本主题只支持高于 **0.62.0** 的 Hugo 版本.
由于 [Markdown 渲染钩子函数](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks) 在 [Hugo 圣诞节版本](https://gohugo.io/news/0.62.0-relnotes/) 中被引入本主题只支持高于 **0.62.0** 的 Hugo 版本
{{< /admonition >}}
{{< admonition tip "推荐使用 Hugo extended 版本" >}}
由于这个主题的一些特性需要将 :(fab fa-sass fa-fw): SCSS 转换为 :(fab fa-css3 fa-fw): CSS, 推荐使用 Hugo **extended** 版本来获得更好的使用体验.
由于这个主题的一些特性需要将 :(fab fa-sass fa-fw): SCSS 转换为 :(fab fa-css3 fa-fw): CSS, 推荐使用 Hugo **extended** 版本来获得更好的使用体验
{{< /admonition >}}
## 2 安装
以下步骤可帮助你初始化新网站. 如果你根本不了解 Hugo, 我们强烈建议你按照此 [快速入门文档](https://gohugo.io/getting-started/quick-start/) 进一步了解它.
以下步骤可帮助你初始化新网站如果你根本不了解 Hugo, 我们强烈建议你按照此 [快速入门文档](https://gohugo.io/getting-started/quick-start/) 进一步了解它
### 2.1 创建你的项目
Hugo 提供了一个 `new` 命令来创建一个新的网站:
Hugo 提供了一个 `new` 命令来创建一个新的网站
```bash
hugo new site my_website
@@ -53,32 +53,32 @@ cd my_website
### 2.2 安装主题
**LoveIt** 主题的仓库是: [https://github.com/dillonzq/LoveIt](https://github.com/dillonzq/LoveIt).
**FixIt** 主题的仓库是<https://github.com/Lruihao/FixIt>
你可以下载主题的 [最新版本 :(far fa-file-archive fa-fw): .zip 文件](https://github.com/dillonzq/LoveIt/releases) 并且解压放到 `themes` 目录.
你可以下载主题的 [最新版本 :(far fa-file-archive fa-fw): .zip 文件](https://github.com/Lruihao/FixIt/releases) 并且解压放到 `themes` 目录
另外, 也可以直接把这个主题克隆到 `themes` 目录:
另外也可以直接把这个主题克隆到 `themes` 目录
```bash
git clone https://github.com/dillonzq/LoveIt.git themes/LoveIt
git clone https://github.com/Lruihao/FixIt.git themes/FixIt
```
或者, 初始化你的项目目录为 git 仓库, 并且把主题仓库作为你的网站目录的子模块:
或者初始化你的项目目录为 git 仓库并且把主题仓库作为你的网站目录的子模块
```bash
git init
git submodule add https://github.com/dillonzq/LoveIt.git themes/LoveIt
git submodule add https://github.com/Lruihao/FixIt.git themes/FixIt
```
### 2.3 基础配置 {#basic-configuration}
以下是 LoveIt 主题的基本配置:
以下是 FixIt 主题的基本配置
```toml
baseURL = "http://example.org/"
# [en, zh-cn, fr, ...] 设置默认的语言
defaultContentLanguage = "zh-cn"
# 网站语言, 仅在这里 CN 大写
# 网站语言仅在这里 CN 大写
languageCode = "zh-CN"
# 是否包括中日韩文字
hasCJKLanguage = true
@@ -86,22 +86,22 @@ hasCJKLanguage = true
title = "我的全新 Hugo 网站"
# 更改使用 Hugo 构建网站时使用的默认主题
theme = "LoveIt"
theme = "FixIt"
[params]
# LoveIt 主题版本
# FixIt 主题版本
version = "0.2.X"
[menu]
[[menu.main]]
identifier = "posts"
# 你可以在名称 (允许 HTML 格式) 之前添加其他信息, 例如图标
# 你可以在名称允许 HTML 格式之前添加其他信息例如图标
pre = ""
# 你可以在名称 (允许 HTML 格式) 之后添加其他信息, 例如图标
# 你可以在名称允许 HTML 格式之后添加其他信息例如图标
post = ""
name = "文章"
url = "/posts/"
# 当你将鼠标悬停在此菜单链接上时, 将显示的标题
# 当你将鼠标悬停在此菜单链接上时将显示的标题
title = ""
weight = 1
[[menu.main]]
@@ -130,26 +130,26 @@ theme = "LoveIt"
```
{{< admonition >}}
在构建网站时, 你可以使用 `--theme` 选项设置主题. 但是, 我建议你修改配置文件 (**config.toml**) 将本主题设置为默认主题.
在构建网站时你可以使用 `--theme` 选项设置主题。但是,我建议你修改配置文件 (**config.toml**) 将本主题设置为默认主题
{{< /admonition >}}
### 2.4 创建你的第一篇文章
以下是创建第一篇文章的方法:
以下是创建第一篇文章的方法
```bash
hugo new posts/first_post.md
```
通过添加一些示例内容并替换文件开头的标题, 你可以随意编辑文章.
通过添加一些示例内容并替换文件开头的标题你可以随意编辑文章
{{< admonition >}}
默认情况下, 所有文章和页面均作为草稿创建. 如果想要渲染这些页面, 请从元数据中删除属性 `draft: true`, 设置属性 `draft: false` 或者为 `hugo` 命令添加 `-D`/`--buildDrafts` 参数.
默认情况下所有文章和页面均作为草稿创建如果想要渲染这些页面请从元数据中删除属性 `draft: true`, 设置属性 `draft: false` 或者为 `hugo` 命令添加 `-D`/`--buildDrafts` 参数
{{< /admonition >}}
### 2.5 在本地启动网站
使用以下命令启动网站:
使用以下命令启动网站
```bash
hugo serve
@@ -160,12 +160,12 @@ hugo serve
![基本配置下的预览](basic-configuration-preview.zh-cn.png "基本配置下的预览")
{{< admonition tip >}}
当你运行 `hugo serve`, 当文件内容更改时, 页面会随着更改自动刷新.
当你运行 `hugo serve`当文件内容更改时页面会随着更改自动刷新
{{< /admonition >}}
{{< admonition >}}
由于本主题使用了 Hugo 中的 `.Scratch` 来实现一些特性,
非常建议你为 `hugo server` 命令添加 `--disableFastRender` 参数来实时预览你正在编辑的文章页面.
由于本主题使用了 Hugo 中的 `.Scratch` 来实现一些特性
非常建议你为 `hugo server` 命令添加 `--disableFastRender` 参数来实时预览你正在编辑的文章页面
```bash
hugo serve --disableFastRender
@@ -174,30 +174,30 @@ hugo serve --disableFastRender
### 2.6 构建网站
当你准备好部署你的网站时, 运行以下命令:
当你准备好部署你的网站时运行以下命令
```bash
hugo
```
会生成一个 `public` 目录, 其中包含你网站的所有静态内容和资源. 现在可以将其部署在任何 Web 服务器上.
会生成一个 `public` 目录其中包含你网站的所有静态内容和资源现在可以将其部署在任何 Web 服务器上
{{< admonition tip >}}
网站内容可以通过 [Netlify](https://www.netlify.com/) 自动发布和托管 (了解有关[通过 Netlify 进行 HUGO 自动化部署](https://www.netlify.com/blog/2015/07/30/hosting-hugo-on-netlifyinsanely-fast-deploys/) 的更多信息).
或者, 您可以使用 [AWS Amplify](https://gohugo.io/hosting-and-deployment/hosting-on-aws-amplify/), [Github pages](https://gohugo.io/hosting-and-deployment/hosting-on-github/), [Render](https://gohugo.io/hosting-and-deployment/hosting-on-render/) 以及更多...
网站内容可以通过 [Netlify](https://www.netlify.com/) 自动发布和托管了解有关 [通过 Netlify 进行 HUGO 自动化部署](https://www.netlify.com/blog/2015/07/30/hosting-hugo-on-netlifyinsanely-fast-deploys/) 的更多信息.
或者您可以使用 [AWS Amplify](https://gohugo.io/hosting-and-deployment/hosting-on-aws-amplify/), [Github pages](https://gohugo.io/hosting-and-deployment/hosting-on-github/), [Render](https://gohugo.io/hosting-and-deployment/hosting-on-render/) 以及更多 ...
{{< /admonition >}}
## 3 配置
### 3.1 网站配置 {#site-configuration}
除了 [Hugo 全局配置](https://gohugo.io/overview/configuration/) 和 [菜单配置](#basic-configuration) 之外, **LoveIt** 主题还允许您在网站配置中定义以下参数 (这是一个示例 `config.toml`, 其内容为默认值).
除了 [Hugo 全局配置](https://gohugo.io/overview/configuration/) 和 [菜单配置](#basic-configuration) 之外**FixIt** 主题还允许您在网站配置中定义以下参数这是一个示例 `config.toml`, 其内容为默认值.
请打开下面的代码块查看完整的示例配置 :(far fa-hand-point-down fa-fw)::
```toml
[params]
# {{< version 0.2.0 changed >}} LoveIt 主题版本
# {{< version 0.2.0 changed >}} FixIt 主题版本
version = "0.2.X"
# 网站描述
description = "这是我的全新 Hugo 网站"
@@ -212,23 +212,27 @@ hugo
fingerprint = ""
# {{< version 0.2.0 >}} 日期格式
dateFormat = "2006-01-02"
# 网站图片, 用于 Open Graph 和 Twitter Cards
# 网站图片用于 Open Graph 和 Twitter Cards
images = ["/logo.png"]
# {{< version 0.2.12 >}} 开启 PWA 支持
enablePWA = true
# {{< version 0.2.0 >}} 应用图标配置
[params.app]
# 当添加到 iOS 主屏幕或者 Android 启动器时的标题, 覆盖默认标题
title = "LoveIt"
# 当添加到 iOS 主屏幕或者 Android 启动器时的标题覆盖默认标题
title = "FixIt"
# 是否隐藏网站图标资源链接
noFavicon = false
# 更现代的 SVG 网站图标, 可替代旧的 .png 和 .ico 文件
# 更现代的 SVG 网站图标可替代旧的 .png 和 .ico 文件
svgFavicon = ""
# Android 浏览器主题色
themeColor = "#ffffff"
# Safari 图标颜色
iconColor = "#5bbad5"
# Windows v8-10磁贴颜色
# Windows v8-10 磁贴颜色
tileColor = "#da532c"
# {{< version 0.2.12 changed >}} Android 浏览器主题色
[params.app.themeColor]
light = "#ffffff"
dark = "#252627"
# {{< version 0.2.0 >}} 搜索配置
[params.search]
@@ -264,17 +268,23 @@ hugo
logo = ""
# 标题名称
name = ""
# 你可以在名称 (允许 HTML 格式) 之前添加其他信息, 例如图标
# 你可以在名称允许 HTML 格式之前添加其他信息例如图标
pre = ""
# 你可以在名称 (允许 HTML 格式) 之后添加其他信息, 例如图标
# 你可以在名称允许 HTML 格式之后添加其他信息例如图标
post = ""
# {{< version 0.2.5 >}} 是否为标题显示打字机动画
typeit = false
# {{< version 0.2.12 >}} 页面头部导航栏副标题配置
[params.header.subtitle]
# 副标题名称
name = ""
# 是否为副标题显示打字机动画
typeit = false
# 页面底部信息配置
[params.footer]
enable = true
# {{< version 0.2.0 >}} 自定义内容 (支持 HTML 格式)
# {{< version 0.2.0 >}} 自定义内容支持 HTML 格式
custom = ''
# {{< version 0.2.0 >}} 是否显示 Hugo 和主题信息
hugo = true
@@ -284,25 +294,27 @@ hugo
author = true
# 网站创立年份
since = 2019
# ICP 备案信息,仅在中国使用 (支持 HTML 格式)
# {{< version 0.2.12 >}} 公网安备信息,仅在中国使用支持 HTML 格式
gov = ""
# {{< version 0.2.12 changed >}} ICP 备案信息,仅在中国使用(支持 HTML 格式)
icp = ""
# 许可协议信息 (支持 HTML 格式)
# 许可协议信息支持 HTML 格式
license = '<a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
# {{< version 0.2.0 >}} Section (所有文章) 页面配置
# {{< version 0.2.0 >}} Section所有文章页面配置
[params.section]
# section 页面每页显示文章数量
paginate = 20
# 日期格式 (月和日)
# 日期格式月和日
dateFormat = "01-02"
# RSS 文章数目
rss = 10
# {{< version 0.2.0 >}} List (目录或标签) 页面配置
# {{< version 0.2.0 >}} List目录或标签页面配置
[params.list]
# list 页面每页显示文章数量
paginate = 20
# 日期格式 (月和日)
# 日期格式月和日
dateFormat = "01-02"
# RSS 文章数目
rss = 10
@@ -318,7 +330,7 @@ hugo
gravatarEmail = ""
# 主页显示头像的 URL
avatarURL = "/images/avatar.png"
# {{< version 0.2.7 changed >}} 主页显示的网站标题 (支持 HTML 格式)
# {{< version 0.2.7 changed >}} 主页显示的网站标题支持 HTML 格式
title = ""
# 主页显示的网站副标题
subtitle = "这是我的全新 Hugo 网站"
@@ -326,16 +338,13 @@ hugo
typeit = true
# 是否显示社交账号
social = true
# {{< version 0.2.0 >}} 免责声明 (支持 HTML 格式)
# {{< version 0.2.0 >}} 免责声明支持 HTML 格式
disclaimer = ""
# 主页文章列表
[params.home.posts]
enable = true
# 主页每页显示文章数量
paginate = 6
# {{< version 0.2.0 deleted >}} 被 params.page 中的 hiddenFromHomePage 替代
# 当你没有在文章前置参数中设置 "hiddenFromHomePage" 时的默认行为
defaultHiddenFromHomePage = false
# 作者的社交信息设置
[params.social]
@@ -420,6 +429,8 @@ hugo
fraction = true
# {{< version 0.2.0 >}} 是否使用 fontawesome 扩展语法
fontawesome = true
# 许可协议信息(支持 HTML 格式)
license = '<a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
# 是否在文章页面显示原始 Markdown 文档链接
linkToMarkdown = true
# {{< version 0.2.4 >}} 是否在 RSS 中显示全文内容
@@ -438,7 +449,7 @@ hugo
copy = true
# 默认展开显示的代码行数
maxShownLines = 10
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} 数学公式
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} 数学公式 (https://katex.org)
[params.page.math]
enable = true
# 默认块定界符是 $$ ... $$ 和 \\[ ... \\]
@@ -451,7 +462,7 @@ hugo
copyTex = true
# KaTeX 插件 mhchem
mhchem = true
# {{< version 0.2.0 >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" "Mapbox GL JS" >}} 配置
# {{< version 0.2.0 >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" "Mapbox GL JS" >}} 配置 (https://docs.mapbox.com/mapbox-gl-js)
[params.page.mapbox]
# Mapbox GL JS 的 access token
accessToken = ""
@@ -500,13 +511,13 @@ hugo
# {{< version 0.2.0 changed >}} 评论系统设置
[params.page.comment]
enable = true
# {{< link "https://disqus.com/" Disqus >}} 评论系统设置
# {{< link "https://disqus.com/" Disqus >}} 评论系统设置 (https://disqus.com)
[params.page.comment.disqus]
# {{< version 0.1.1 >}}
enable = false
# Disqus 的 shortname,用来在文章中启用 Disqus 评论系统
shortname = ""
# {{< link "https://github.com/gitalk/gitalk" Gitalk >}} 评论系统设置
# {{< link "https://github.com/gitalk/gitalk" Gitalk >}} 评论系统设置 (https://github.com/gitalk/gitalk)
[params.page.comment.gitalk]
# {{< version 0.1.1 >}}
enable = false
@@ -514,7 +525,7 @@ hugo
repo = ""
clientId = ""
clientSecret = ""
# {{< link "https://github.com/xCss/Valine" Valine >}} 评论系统设置
# {{< link "https://github.com/xCss/Valine" Valine >}} 评论系统设置 (https://github.com/xCss/Valine)
[params.page.comment.valine]
enable = false
appId = ""
@@ -529,20 +540,20 @@ hugo
highlight = true
enableQQ = false
serverURLs = ""
# {{< version 0.2.6 >}} emoji 数据文件名称, 默认是 "google.yml"
# {{< version 0.2.6 >}} emoji 数据文件名称默认是 "google.yml"
# ("apple.yml", "google.yml", "facebook.yml", "twitter.yml")
# 位于 "themes/LoveIt/assets/data/emoji/" 目录
# 可以在你的项目下相同路径存放你自己的数据文件:
# 位于 "themes/FixIt/assets/data/emoji/" 目录
# 可以在你的项目下相同路径存放你自己的数据文件
# "assets/data/emoji/"
emoji = ""
# {{< link "https://developers.facebook.com/docs/plugins/comments" "Facebook 评论系统" >}}设置
# {{< link "https://developers.facebook.com/docs/plugins/comments" "Facebook 评论系统" >}}设置 (https://developers.facebook.com/docs/plugins/comments)
[params.page.comment.facebook]
enable = false
width = "100%"
numPosts = 10
appId = ""
languageCode = "zh_CN"
# {{< version 0.2.0 >}} {{< link "https://comments.app/" "Telegram Comments" >}} 评论系统设置
# {{< version 0.2.0 >}} {{< link "https://comments.app/" "Telegram Comments" >}} 评论系统设置 (https://comments.app)
[params.page.comment.telegram]
enable = false
siteID = ""
@@ -552,10 +563,10 @@ hugo
colorful = true
dislikes = false
outlined = false
# {{< version 0.2.0 >}} {{< link "https://commento.io/" "Commento" >}} 评论系统设置
# {{< version 0.2.0 >}} {{< link "https://commento.io/" "Commento" >}} 评论系统设置 (https://commento.io)
[params.page.comment.commento]
enable = false
# {{< version 0.2.5 >}} {{< link "https://utteranc.es/" "Utterances" >}} 评论系统设置
# {{< version 0.2.5 >}} {{< link "https://utteranc.es/" "Utterances" >}} 评论系统设置 (https://utteranc.es)
[params.page.comment.utterances]
enable = false
# owner/repo
@@ -587,14 +598,45 @@ hugo
# {{< version 0.2.5 >}} TypeIt 配置
[params.typeit]
# 每一步的打字速度 (单位是毫秒)
# 每一步的打字速度单位是毫秒
speed = 100
# 光标的闪烁速度 (单位是毫秒)
# 光标的闪烁速度单位是毫秒
cursorSpeed = 1000
# 光标的字符 (支持 HTML 格式)
# 光标的字符支持 HTML 格式
cursorChar = "|"
# 打字结束之后光标的持续时间 (单位是毫秒, "-1" 代表无限大)
# 打字结束之后光标的持续时间单位是毫秒"-1" 代表无限大
duration = -1
# {{< version 0.2.12 >}} 水印配置
# 详细参数见 https://github.com/Lruihao/watermark#readme
[params.watermark]
enable = false
# 水印内容(允许 HTML 格式)
content = ''
# 水印透明度
opacity = 0.1
# 水印父节点
appendTo = '.wrapper>.main'
# 单水印宽度 单位:px
width = 150
# 单水印高度 单位:px
height = 20
# 水印行间距 单位:px
rowSpacing = 60
# 水印列间距 单位:px
colSpacing = 30
# 水印旋转角度 单位:deg
rotate = 15
# 水印字体大小,单位:rem
fontSize = 0.85
# {{< version 0.2.12 >}} 不蒜子统计
[params.ibruce]
enable = true
# 在文章中开启
enablePost = false
# 网站创立时间 例:'2019-02-03T19:30:34+08:00'
siteTime = ''
# 网站验证代码,用于 Google/Bing/Yandex/Pinterest/Baidu
[params.verification]
@@ -636,12 +678,12 @@ hugo
# {{< version 0.2.7 changed >}} 第三方库文件的 CDN 设置
[params.cdn]
# CDN 数据文件名称, 默认不启用
# CDN 数据文件名称默认不启用
# ("jsdelivr.yml")
# 位于 "themes/LoveIt/assets/data/cdn/" 目录
# 可以在你的项目下相同路径存放你自己的数据文件:
# 位于 "themes/FixIt/assets/data/cdn/" 目录
# 可以在你的项目下相同路径存放你自己的数据文件
# "assets/data/cdn/"
data = ""
# data = "jsdelivr.yml"
# {{< version 0.2.8 >}} 兼容性设置
[params.compatibility]
@@ -652,14 +694,13 @@ hugo
# Hugo 解析文档的配置
[markup]
# {{< link "https://gohugo.io/content-management/syntax-highlighting" "语法高亮设置" >}}
# {{< link "https://gohugo.io/content-management/syntax-highlighting" "语法高亮设置" >}} (https://gohugo.io/content-management/syntax-highlighting)
[markup.highlight]
codeFences = true
guessSyntax = true
lineNos = true
lineNumbersInTable = true
# false 是必要的设置
# ({{< link "https://github.com/dillonzq/LoveIt/issues/158" >}})
# false 是必要的设置 (https://github.com/dillonzq/LoveIt/issues/158)
noClasses = false
# Goldmark 是 Hugo 0.60 以来的默认 Markdown 解析库
[markup.goldmark]
@@ -691,16 +732,13 @@ hugo
filename = "sitemap.xml"
priority = 0.5
# {{< link "https://gohugo.io/content-management/urls#permalinks" "Permalinks 配置" >}}
# {{< link "https://gohugo.io/content-management/urls#permalinks" "Permalinks 配置" >}} (https://gohugo.io/content-management/urls#permalinks)
[Permalinks]
# posts = ":year/:month/:filename"
posts = ":filename"
# {{< link "https://gohugo.io/about/hugo-and-gdpr/" "隐私信息配置" >}}
# {{< link "https://gohugo.io/about/hugo-and-gdpr/" "隐私信息配置" >}} (https://gohugo.io/about/hugo-and-gdpr/)
[privacy]
# {{< version 0.2.0 deleted >}} Google Analytics 相关隐私 (被 params.analytics.google 替代)
[privacy.googleAnalytics]
# ...
[privacy.twitter]
enableDNT = true
[privacy.youtube]
@@ -728,17 +766,17 @@ hugo
```
{{< admonition >}}
请注意, 本文档其他部分将详细解释其中一些参数.
请注意本文档其他部分将详细解释其中一些参数
{{< /admonition >}}
{{< admonition note "Hugo 的运行环境" >}}
`hugo serve` 的默认运行环境是 `development`,
`hugo` 的默认运行环境是 `production`.
由于本地 `development` 环境的限制,
**评论系统**, **CDN****fingerprint** 不会在 `development` 环境下启用.
由于本地 `development` 环境的限制
**评论系统**, **CDN****fingerprint** 不会在 `development` 环境下启用
你可以使用 `hugo serve -e production` 命令来开启这些特性.
你可以使用 `hugo serve -e production` 命令来开启这些特性
{{< /admonition >}}
{{< admonition tip "关于 CDN 配置的技巧" >}}
@@ -746,19 +784,19 @@ hugo
```toml
[params.cdn]
# CDN 数据文件名称, 默认不启用
# CDN 数据文件名称默认不启用
# ("jsdelivr.yml")
data = ""
````
CDN `themes/LoveIt/assets/data/cdn/` .
: `assets/data/cdn/`.
CDN `themes/FixIt/assets/data/cdn/`
`assets/data/cdn/`.
{{< /admonition >}}
{{< admonition tip "关于社交链接配置的技巧" >}}
{{< version 0.2.0 >}}
ID :
ID
```toml
[params.social]
@@ -767,12 +805,12 @@ hugo
生成的社交链接是 `https://mastodon.technology/@xxxx`.
或者你可以通过一个字典来设置更多的选项:
或者你可以通过一个字典来设置更多的选项
```toml
[params.social]
[params.social.Mastodon]
# 排列图标时的权重 (权重越大, 图标的位置越靠后)
# 排列图标时的权重权重越大图标的位置越靠后
weight = 0
# 你的社交 ID
id = "@xxxx"
@@ -782,15 +820,15 @@ hugo
title = "Mastodon"
```
所有支持的社交链接的默认数据位于 `themes/LoveIt/assets/data/social.yaml`.
你可以参考它来配置你的社交链接.
所有支持的社交链接的默认数据位于 `themes/FixIt/assets/data/social.yaml`.
你可以参考它来配置你的社交链接
{{< /admonition >}}
![完整配置下的预览](complete-configuration-preview.zh-cn.png "完整配置下的预览")
### 3.2 网站图标, 浏览器配置, 网站清单
### 3.2 网站图标浏览器配置网站清单
强烈建议你把:
强烈建议你把
* apple-touch-icon.png (180x180)
* favicon-32x32.png (32x32)
@@ -799,7 +837,7 @@ hugo
* android-chrome-192x192.png (192x192)
* android-chrome-512x512.png (512x512)
放在 `/static` 目录. 利用 [https://realfavicongenerator.net/](https://realfavicongenerator.net/) 可以很容易地生成这些文件.
放在 `/static` 目录利用 [https://realfavicongenerator.net/](https://realfavicongenerator.net/) 可以很容易地生成这些文件
可以自定义 `browserconfig.xml``site.webmanifest` 文件来设置 theme-color 和 background-color.
@@ -808,27 +846,27 @@ hugo
{{< version 0.2.8 changed >}}
{{< admonition >}}
Hugo **extended** 版本对于自定义样式是必需的.
Hugo **extended** 版本对于自定义样式是必需的
{{< /admonition >}}
通过定义自定义 `.scss` 样式文件, **LoveIt** 主题支持可配置的样式.
通过定义自定义 `.scss` 样式文件**FixIt** 主题支持可配置的样式
包含自定义 `.scss` 样式文件的目录相对于 **你的项目根目录** 的路径为 `assets/css`.
`assets/css/_override.scss`, 你可以覆盖 `themes/LoveIt/assets/css/_variables.scss` 中的变量以自定义样式.
`assets/css/_override.scss`你可以覆盖 `themes/FixIt/assets/css/_variables.scss` 中的变量以自定义样式
这是一个例子:
这是一个例子
```scss
@import url('https://fonts.googleapis.com/css?family=Fira+Mono:400,700&display=swap&subset=latin-ext');
$code-font-family: Fira Mono, Source Code Pro, Menlo, Consolas, Monaco, monospace;
```
`assets/css/_custom.scss`, 你可以添加一些 CSS 样式代码以自定义样式.
`assets/css/_custom.scss`你可以添加一些 CSS 样式代码以自定义样式
## 4 多语言和 i18n
**LoveIt** 主题完全兼容 Hugo 的多语言模式, 并且支持在网页上切换语言.
**FixIt** 主题完全兼容 Hugo 的多语言模式并且支持在网页上切换语言
![语言切换](language-switch.gif "语言切换")
@@ -837,7 +875,7 @@ $code-font-family: Fira Mono, Source Code Pro, Menlo, Consolas, Monaco, monospac
{{< version 0.2.10 changed >}}
| 语言 | Hugo 代码 | HTML `lang` 属性 | 主题文档 | Lunr.js 支持 |
|:---- |:----:|:----:|:----:|:----:|
|:----|:----:|:----:|:----:|:----:|
| 英语 | `en` | `en` | :(far fa-check-square fa-fw): | :(far fa-check-square fa-fw): |
| 简体中文 | `zh-cn` | `zh-CN` | :(far fa-check-square fa-fw): | :(far fa-check-square fa-fw): |
| 法语 | `fr` | `fr` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
@@ -850,12 +888,13 @@ $code-font-family: Fira Mono, Source Code Pro, Menlo, Consolas, Monaco, monospac
| 俄语 | `ru` | `ru` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| 罗马尼亚语 | `ro` | `ro` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| 越南语 | `vi` | `vi` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
| 繁体中文 | `zh-tw` | `zh-TW` | :(far fa-square fa-fw): | :(far fa-check-square fa-fw): |
### 4.2 基本配置
学习了 [Hugo如何处理多语言网站](https://gohugo.io/content-management/multilingual) 之后, 请在 [站点配置](#site-configuration) 中定义你的网站语言.
学习了 [Hugo 如何处理多语言网站](https://gohugo.io/content-management/multilingual) 之后请在 [站点配置](#site-configuration) 中定义你的网站语言
例如, 一个支持英语, 中文和法语的网站配置:
例如一个支持英语中文和法语的网站配置
```toml
# [en, zh-cn, fr, pl, ...] 设置默认的语言
@@ -895,7 +934,7 @@ defaultContentLanguage = "zh-cn"
[languages.zh-cn]
weight = 2
title = "我的全新 Hugo 网站"
# 网站语言, 仅在这里 CN 大写
# 网站语言仅在这里 CN 大写
languageCode = "zh-CN"
languageName = "简体中文"
# 是否包括中日韩文字
@@ -956,40 +995,40 @@ defaultContentLanguage = "zh-cn"
weight = 3
```
然后, 对于每个新页面, 将语言代码附加到文件名中.
然后对于每个新页面将语言代码附加到文件名中
单个文件 `my-page.md` 需要分为三个文件:
单个文件 `my-page.md` 需要分为三个文件
* 英语: `my-page.en.md`
* 中文: `my-page.zh-cn.md`
* 法语: `my-page.fr.md`
* 英语`my-page.en.md`
* 中文`my-page.zh-cn.md`
* 法语`my-page.fr.md`
{{< admonition >}}
请注意, 菜单中仅显示翻译的页面. 它不会替换为默认语言内容.
请注意菜单中仅显示翻译的页面它不会替换为默认语言内容
{{< /admonition >}}
{{< admonition tip >}}
也可以使用 [文章前置参数](https://gohugo.io/content-management/multilingual#translate-your-content) 来翻译网址.
也可以使用 [文章前置参数](https://gohugo.io/content-management/multilingual#translate-your-content) 来翻译网址
{{< /admonition >}}
### 4.3 修改默认的翻译字符串
翻译字符串用于在主题中使用的常见默认值.
目前提供[一些语言](#language-compatibility)的翻译, 但你可能自定义其他语言或覆盖默认值.
翻译字符串用于在主题中使用的常见默认值
目前提供 [一些语言](#language-compatibility) 的翻译但你可能自定义其他语言或覆盖默认值
要覆盖默认值, 请在你项目的 i18n 目录 `i18n/<languageCode>.toml` 中创建一个新文件,并从 `themes/LoveIt/i18n/en.toml` 中获得提示.
要覆盖默认值请在你项目的 i18n 目录 `i18n/<languageCode>.toml` 中创建一个新文件,并从 `themes/FixIt/i18n/en.toml` 中获得提示
另外, 由于你的翻译可能会帮助到其他人, 请花点时间通过 [:(fas fa-code-branch fa-fw): 创建一个 PR](https://github.com/dillonzq/LoveIt/pulls) 来贡献主题翻译, 谢谢!
另外由于你的翻译可能会帮助到其他人请花点时间通过 [:(fas fa-code-branch fa-fw): 创建一个 PR](https://github.com/Lruihao/FixIt/pulls) 来贡献主题翻译谢谢
## 5 搜索
{{< version 0.2.0 >}}
基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/), **LoveIt** 主题支持搜索功能.
基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/), **FixIt** 主题支持搜索功能
### 5.1 输出配置
为了生成搜索功能所需要的 `index.json`, 请在你的 [网站配置](#site-configuration) 中添加 `JSON` 输出文件类型到 `outputs` 部分的 `home` 字段中.
为了生成搜索功能所需要的 `index.json`, 请在你的 [网站配置](#site-configuration) 中添加 `JSON` 输出文件类型到 `outputs` 部分的 `home` 字段中
```toml
[outputs]
@@ -998,9 +1037,9 @@ defaultContentLanguage = "zh-cn"
### 5.2 搜索配置
基于 Hugo 生成的 `index.json` 文件, 你可以激活搜索功能.
基于 Hugo 生成的 `index.json` 文件你可以激活搜索功能
这是你的 [网站配置](#site-configuration) 中的搜索部分:
这是你的 [网站配置](#site-configuration) 中的搜索部分
```toml
[params.search]
@@ -1025,18 +1064,24 @@ defaultContentLanguage = "zh-cn"
searchKey = ""
```
{{< admonition note "怎样选择搜索引擎?" >}}
以下是两种搜索引擎的对比:
{{< admonition note "怎样选择搜索引擎" >}}
以下是两种搜索引擎的对比
* `lunr`: 简单, 无需同步 `index.json`, 没有 `contentLength` 的限制, 但占用带宽大且性能低 (特别是中文需要一个较大的分词依赖库)
* `algolia`: 高性能并且占用带宽低, 但需要同步 `index.json` 且有 `contentLength` 的限制
* `lunr`: 简单无需同步 `index.json`, 没有 `contentLength` 的限制但占用带宽大且性能低特别是中文需要一个较大的分词依赖库
* `algolia`: 高性能并且占用带宽低但需要同步 `index.json` 且有 `contentLength` 的限制
{{< version 0.2.3 >}} 文章内容被 `h2``h3` HTML 标签切分来提高查询效果并且基本实现全文搜索.
`contentLength` 用来限制 `h2``h3` HTML 标签开头的内容部分的最大长度.
{{< version 0.2.3 >}} 文章内容被 `h2``h3` HTML 标签切分来提高查询效果并且基本实现全文搜索
`contentLength` 用来限制 `h2``h3` HTML 标签开头的内容部分的最大长度
{{< /admonition >}}
{{< admonition tip "关于 algolia 的使用技巧" >}}
你需要上传 `index.json` 到 algolia 来激活搜索功能. 你可以使用浏览器来上传 `index.json` 文件但是一个自动化的脚本可能效果更好.
[Algolia Atomic](https://github.com/chrisdmacrae/atomic-algolia) 是一个不错的选择.
为了兼容 Hugo 的多语言模式, 你需要上传不同语言的 `index.json` 文件到对应的 algolia index, 例如 `zh-cn/index.json``fr/index.json`...
你需要上传 `index.json` 到 algolia 来激活搜索功能你可以使用浏览器来上传 `index.json` 文件但是一个自动化的脚本可能效果更好
[Algolia Atomic](https://github.com/chrisdmacrae/atomic-algolia) 是一个不错的选择
为了兼容 Hugo 的多语言模式你需要上传不同语言的 `index.json` 文件到对应的 algolia index, 例如 `zh-cn/index.json``fr/index.json`...
{{< /admonition >}}
---
{{< admonition quote "感谢" >}}
_本文档中 `v0.2.10` 版本之前的内容,感谢原作者 [Dillon](https://dillonzq.com) 编写修订。_
{{< /admonition >}}