Merge remote-tracking branch 'weaxs/translations-v1' into translations-v1

This commit is contained in:
Aphcity
2024-03-20 18:44:18 +08:00
parent 4a95a42286
commit 4ef29d4697
16 changed files with 670 additions and 629 deletions

View File

@@ -1,83 +1,82 @@
---
title: "Installation"
title: "安装和配置"
date: 2020-08-16
draft: false
description: "How to install the Blowfish theme."
description: "如何安装 Blowfish 主题。"
slug: "installation"
tags: ["installation", "docs"]
series: ["Documentation"]
tags: ["安装", "文档"]
series: ["文档集合"]
series_order: 2
---
Simply follow the standard Hugo [Quick Start](https://gohugo.io/getting-started/quick-start/) procedure to get up and running quickly.
如果想快速上有,可以按照标准的 Hugo [快速启动](https://gohugo.io/getting-started/quick-start/) 文档。
Detailed installation instructions can be found below. Instructions for [updating the theme](#installing-updates) are also available.
更详细的安装如下,[更新主题](#installing-updates)的教程也可以看此文档。
## Installation
## 前言
These instructions will get you up and running using Hugo and Blowfish from a completely blank state. Most of the dependencies mentioned in this guide can be installed using the package manager of choice for your platform.
本文将一步一步指导你学会使用 Hugo Blowfish。本文中提到的大多数依赖项都可以在任意你想使用的平台中使用和安装。
### Install Hugo
### 安装 Hugo
If you haven't used Hugo before, you will need to [install it onto your local machine](https://gohugo.io/getting-started/installing). You can check if it's already installed by running the command `hugo version`.
如果你之前没有使用过 Hugo你首先需要了解[在本地机器安装 Hugo](https://gohugo.io/getting-started/installing)。你可以通过运行命令 `hugo version` 来检查是否安装完成。
{{< alert >}}
Make sure you are using **Hugo version 0.87.0** or later as the theme takes advantage of some of the latest Hugo features.
确保你使用 **Hugo 0.87.0** 或更高的版本Blowfish 主题中使用了最新的 Hugo 特性。
{{< /alert >}}
You can find detailed installation instructions for your platform in the [Hugo docs](https://gohugo.io/getting-started/installing).
你可以在 [Hugo 文档](https://gohugo.io/getting-started/installing) 中找到不同平台更加详细的安装指南。
### Blowfish Tools (recommended)
### 使用 Blowfish-Tools 工具安装 (推荐)
We just launched a new CLI tool to help you get started with Blowfish. It will create a new Hugo project, install the theme and set up the theme configuration files for you. It's still in beta so please [report any issues you find](https://github.com/nunocoracao/blowfish-tools).
我们刚刚推出了一个 CLI 工具,帮助你首次使用 Blowfish。该工具将会为你创建一个新的 Hugo 项目、安装 Blowfish 主题并设置配置文件。但目前该工具仍处于测试阶段,如果遇到任何问题,请随时[提交 issues](https://github.com/nunocoracao/blowfish-tools)
Install the CLI tool globally using npm (or other package manager):
使用 `npm` 包或其他的包管理器,在全局环境中安装 CLI
```shell
npx blowfish-tools
```
or
或者
```shell
npm i -g blowfish-tools
```
Then run the command `blowfish-tools` to start an interactive run which will guide you through creation and configuration use-cases.
然后运行 `blowfish-tools` 命令,它将引导你完成创建和配置用例。
```shell
blowfish-tools
```
You can also run the command `blowfish-tools new` to create a new Hugo project and install the theme in one go. Check the CLI help for more information.
你也可以运行 `blowfish-tools new` 命令来创建一个新的 Hugo 项目,并且一次性地安装主题。查看 CLI 帮助以获取更多信息。
```shell
blowfish-tools new mynewsite
```
Here's a quick video of how fast it is to get started with Blowfish using the CLI tool:
下面是一个简短的视频,介绍了如何使用 CLI 工具快速构建 Blowfish
<iframe width="100%" height="350" src="https://www.youtube.com/embed/SgXhGb-7QbU?si=ce44baicuQ6zMeXz" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
### Install Manually
### 手动安装
#### Create a new site
#### 创建新站点
Run the command `hugo new site mywebsite` to create a new Hugo site in a directory named `mywebsite`.
运行 `hugo new site mywebsite` 命令,可以在`mywebsite`目录下创建一个新的 Hugo 站点。
Note that you can name the project directory whatever you choose, but the instructions below will assume it's named `mywebsite`. If you use a different name, be sure to substitute it accordingly.
下面会以 `mywebsite` 为例展开说明。当然你完全可以使用任何你喜欢的目录名称,但在阅读下面的内容时,请记得将`mywebsite`替换为此。
#### Download the Blowfish theme
#### 下载 Blowfish 主题
There several different ways to install the Blowfish theme into your Hugo website. From easiest to most difficult to install and maintain, they are:
有多种方法可以将 Blowfish 主题安装在 Hugo 站点中。下面我们由易到难逐一介绍:
- [Git submodule](#install-using-git) (recommended)
- [Hugo module](#install-using-hugo)
- [Manual file copy](#install-manually)
- [使用 Git 子模块安装](#install-using-git) (推荐)
- [使用 Hugo 模块安装](#install-using-hugo)
- [手动文件复制](#install-manually)
If you're unsure, choose the Git submodule method.
如果你不确定用哪一个,请直接选择 Git 子模块的方式。
##### Install using git
##### 使用 Git 子模块安装
This method is the quickest and easiest for keeping the theme up-to-date. Besides **Hugo** and **Go**, you'll also need to ensure you have **Git** installed on your local machine.
这个方法可以保证主题简单且快速地安装和更新。除了 **Hugo** **Go**,你还需要确保本地机器安装了 **Git**
Change into the directory for your Hugo website (that you created above), initialise a new `git` repository and add Blowfish as a submodule.
进入你刚才创建的网站目录 `mywebsite`,初始化一个新的 `git` 仓库并将 Blowfish 添加为子模块。
```bash
cd mywebsite
@@ -85,61 +84,61 @@ git init
git submodule add -b main https://github.com/nunocoracao/blowfish.git themes/blowfish
```
Then continue to [set up the theme configuration files](#set-up-theme-configuration-files).
然后 [设置主题的配置文件](#set-up-theme-configuration-files)
##### Install using Hugo
##### 使用 Hugo 模板安装
For this method you'll use Hugo to manage your themes. Hugo uses **Go** to initialise and manage modules so you need to ensure you have `go` installed before proceeding.
这种方法是使用 Hugo 来管理你的主题,Hugo 使用 **Go** 来初始化和管理模块,所以首先需要确保已经安装了`go`
1. [Download](https://golang.org/dl/) and install Go. You can check if it's already installed by using the command `go version`.
1. [下载](https://golang.org/dl/) 并安装 Go。你可以使用 `go version` 命令来检查是否安装。
{{< alert >}}
Make sure you are using **Go version 1.12** or later as Hugo requires this for modules to work correctly.
确保你使用 **Go 1.12** 或 更高的版本Hugo 需要这个版本才能加载模块。
{{< /alert >}}
2. From your Hugo project directory (that you created above), initialise modules for your website:
2. 在你刚才创建的网站目录 `mywebsite`下,为你的网站初始化模块:
```shell
# If you're managing your project on GitHub
# 如果你在 Github 上管理你的项目
hugo mod init github.com/<username>/<repo-name>
# If you're managing your project locally
# 如果你在本地管理你的项目
hugo mod init my-project
```
3. Add the theme to your configuration by creating a new file `config/_default/module.toml` and adding the following:
3. 创建一个新文件 `config/_default/module.toml`,并添加下面的内容来配置主题:
```toml
[[imports]]
path = "github.com/nunocoracao/blowfish/v2"
```
4. Start your server using `hugo server` and the theme will be downloaded automatically.
5. Continue to [set up the theme configuration files](#set-up-theme-configuration-files).
4. 使用`hugo server` 命令后,主题将会自动下载。
5. 然后 [设置主题的配置文件](#set-up-theme-configuration-files).
##### Install manually
##### 手动复制文件
1. Download the latest release of the theme source code.
1. 下载最新的主题源码。
{{< button href="https://github.com/nunocoracao/blowfish/releases/latest" target="_blank" >}}Download from Github{{< /button >}}
{{< button href="https://github.com/nunocoracao/blowfish/releases/latest" target="_blank" >}} Github 下载{{< /button >}}
2. Extract the archive, rename the folder to `blowfish` and move it to the `themes/` directory inside your Hugo project's root folder.
3. Continue to [set up the theme configuration files](#set-up-theme-configuration-files).
2. 解压缩, 并将文件夹重命名为 `blowfish`,将其移动到你的 Hugo 项目根目录下的 `themes/` 目录中。
3. 然后 [设置主题的配置文件](#set-up-theme-configuration-files).
#### Set up theme configuration files
#### 设置主题的配置文件
In the root folder of your website, delete the `config.toml` file that was generated by Hugo. Copy the `*.toml` config files from the theme into your `config/_default/` folder. This will ensure you have all the correct theme settings and will enable you to easily customise the theme to your needs.
在你的网站根目录中,删除 Hugo 自动生成的 `config.toml` 文件。从主题中复制 `*.toml` 文件,粘贴到 `config/_default/` 目录中。这将确保你的主题设置准确无误,在此基础上你能够轻松地自定义主题。
{{< alert >}}
**Note:** You should not overwrite the `module.toml` file if one already exists in your project!
**注意:** 如果项目中已经存在 `module.toml` 文件,请不要覆盖它!
{{< /alert >}}
Depending on how you installed the theme you will find the theme config files in different places:
根据你安装主题的不同方式,你可以在以下地方找到主题的配置文件:
- **Hugo Modules:** In the Hugo cache directory, or [download a copy](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/nunocoracao/blowfish/tree/main/config/_default) from GitHub
- **Git submodule or Manual install:** `themes/blowfish/config/_default`
- **Hugo 模块:** 在 Hugo 的缓存目录, 或者从 Github [下载副本](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/nunocoracao/blowfish/tree/main/config/_default) from GitHub
- **Git 子模块 或 本地复制文件:** `themes/blowfish/config/_default`
Once you've copied the files, your config folder should look like this:
一旦你复制了这些文件,你的 config 目录看起来应该是这样:
```shell
config/_default/
@@ -147,64 +146,64 @@ config/_default/
├─ languages.en.toml
├─ markup.toml
├─ menus.en.toml
├─ module.toml # if you installed using Hugo Modules
├─ module.toml # 通过 Hugo 模块安装
└─ params.toml
```
{{< alert >}}
**Important:** If you didn't use Hugo Modules to install Blowfish, you must add the line `theme = "blowfish"` to the top of your `config.toml` file.
**重要:** 如果你没有使用 Hugo 模块安装 Blowfish那么你必须在 `config.toml` 文件中添加 `theme = "blowfish"`。
{{< /alert >}}
### Next steps
### 下一步
The basic Blowfish installation is now complete. Continue to the [Getting Started]({{< ref "getting-started" >}}) section to learn more about configuring the theme.
基本的 Blowfish 安装已经完成。继续阅读 [入门指南]({{< ref "getting-started" >}}),了解更多关于主题配置的内容。
---
## Installing updates
## 更新主题
From time to time there will be [new releases](https://github.com/nunocoracao/blowfish/releases) posted that apply fixes and add new functionality to the theme. In order to take advantage of these changes, you will need to update the theme files on your website.
经常会有 [新版本](https://github.com/nunocoracao/blowfish/releases) 的主题发布,这些版本主要是修复 bug 和添加新功能。如果想要用到新版本的功能,那么你需要更新网站的主题。
How you go about this will depend on the installation method you chose when the theme was originally installed. Instructions for each method can be found below.
如何更新主题取决于最初安装主题时选择的安装方式,具体如下:
- [Git submodule](#update-using-git)
- [Hugo module](#update-using-hugo)
- [Manual file copy](#update-manually)
- [使用 Git 子模块安装](#update-using-git)
- [使用 Hugo 模块安装](#update-using-hugo)
- [手动文件复制](#update-manually)
### Update using git
### 利用 git 更新
Git submodules can be updated using the `git` command. Simply execute the following command and the latest version of the theme will be downloaded into your local repository:
Git 子模块的方式,可以使用 `git` 命令更新。只需执行以下命令,最新版的主题将会下载到你的本地仓库中:
```shell
git submodule update --remote --merge
```
Once the submodule has been updated, rebuild your site and check everything works as expected.
一旦子模块更新完毕,请检查你的确实是否一切正常。
### Update using Hugo
Hugo makes updating modules super easy. Simply change into your project directory and execute the following command:
Hugo 更新也十分容易。只需要进入网站根目录,并执行以下命令即可:
```shell
hugo mod get -u
```
Hugo will automatically update any modules that are required for your project. It does this by inspecting your `module.toml` and `go.mod` files. If you have any issues with the update, check to ensure these files are still configured correctly.
Hugo 将自动更新项目中所需的任何模块。它通过检查 `module.toml` `go.mod` 来实现的。如果你在更新过程中遇到任何问题,请确保这两个文件是正常配置的。
Then simply rebuild your site and check everything works as expected.
重建完毕后,请检查网站是否一切正常。
### Update manually
### 手动更新
Updating Blowfish manually requires you to download the latest copy of the theme and replace the old version in your project.
手动更新 Blowfish 需要下载主题的最新副本,并替换项目中的旧版本。
{{< alert >}}
Note that any local customisations you have made to the theme files will be lost during this process.
注意:在手动替换过程中,你对主题文件中所做的任何修改都会丢失。
{{< /alert >}}
1. Download the latest release of the theme source code.
1. 下载主题最新版本的源码。
{{< button href="https://github.com/nunocoracao/blowfish/releases/latest" target="_blank" >}}Download from Github{{< /button >}}
{{< button href="https://github.com/nunocoracao/blowfish/releases/latest" target="_blank" >}} Github 下载{{< /button >}}
2. Extract the archive, rename the folder to `blowfish` and move it to the `themes/` directory inside your Hugo project's root folder. You will need to overwrite the existing directory to replace all the theme files.
2. 解压缩, 将文件夹重命名为 `blowfish`,并移动到根目录 `themes/` 目录下。你需要覆盖旧版以替换所有的主题文件。
3. Rebuild your site and check everything works as expected.
3. 重建站点,并检查网站是否一切正常。