midtowndrafting.com/content/docs/getting-started.zh-cn.md
2024-05-03 19:04:48 -04:00

3.5 KiB
Raw Blame History

title weight next prev
快速开始 1 /docs/guide /docs

使用模板快速开始

{{< icon "github" >}} imfing/hextra-starter-template

通过使用上面的模板仓库,您将能够快速地开始。

我们提供了一个 GitHub Actions 工作流,它可以帮助您自动构建并部署您的网站到 GitHub Pages并免费托管。

🌐 演示 ↗

作为新项目开始

前提条件

在开始之前,请确保我们已经安装了 Hugo。 请参考 Hugo 的官方安装指南以获取更多详情。

Hugo 模块是管理 Hugo 主题的推荐方式。要使用 Hugo 模块,我们需要安装 GitGo

初始化 Hugo 站点

hugo new site my-site --format=yaml

通过 Hugo Module 安装

# 初始化 Hugo 模块
cd my-site
hugo mod init github.com/username/my-site

# 添加 Hextra 
hugo mod get github.com/imfing/hextra

编辑 hugo.yaml 以启用 Hextra

module:
  imports:
    - path: github.com/imfing/hextra

通过 Git Submodule 安装

先决条件

在我们开始之前,你必须先确保以下软件已经安装:

步骤

{{% steps %}}

初始化 Hugo 站点

hugo new site my-site --format=yaml

将 Hextra 添加为 Git Submodule

git submodule add https://github.com/imfing/hextra.git themes/hextra

添加以下内容来配置 hugo.yaml 以使用 Hextra

theme: hextra

创建你的第一个内容页

让我们为主页和文档页面创建一个新的内容页面:

hugo new content/_index.md
hugo new content/docs/_index.md

在本地预览站点

hugo server --buildDrafts --disableFastRender

瞧!你现在可以在 http://localhost:1313/ 看到你的新站点。

{{% /steps %}}

使用 CI/CD 进行部署时,必须确保在运行 hugo 命令之前执行以下命令。

git submodule update --init

如果不运行此命令theme 中将不会存在 Hextra 文件,进而导致构建失败。

{{% details title="如何更新主题?" %}}

如需把项目中所有的 Hugo Modules 都升级到最新,在终端中运行此命令:

hugo mod get -u

如需把 Hextra 升级到最新的发行版本, 在终端中运行此命令:

hugo mod get -u github.com/imfing/hextra

如果你需要获得更多信息,参见 Hugo Modules.

{{% /details %}}

接下来

探索这些文档以便添加更多内容:

{{< cards >}} {{< card link="../guide/organize-files" title="Organize Files" icon="document-duplicate" >}} {{< card link="../guide/configuration" title="Configuration" icon="adjustments" >}} {{< card link="../guide/markdown" title="Markdown" icon="markdown" >}} {{< /cards >}}