Plausible-Hugo 项目使用教程
1. 项目目录结构及介绍
plausible-hugo/
├── layouts/
│ └── partials/
│ └── plausible_head.html
├── i18n/
├── LICENSE
├── README.md
├── config.toml
├── go.mod
├── theme.yaml
└── static/
└── _redirects
目录结构介绍
- layouts/: 存放项目的布局文件,其中
partials/
目录下包含部分布局文件,如plausible_head.html
。 - i18n/: 国际化文件目录,用于多语言支持。
- LICENSE: 项目的开源许可证文件。
- README.md: 项目的说明文档。
- config.toml: 项目的配置文件。
- go.mod: Go 模块文件,用于管理项目的依赖。
- theme.yaml: 主题配置文件。
- static/: 静态文件目录,如
_redirects
文件用于重定向配置。
2. 项目启动文件介绍
项目的主要启动文件是 config.toml
,它包含了项目的配置信息。启动项目时,Hugo 会读取该文件并根据其中的配置进行初始化。
config.toml 示例
theme = ["plausible-hugo"]
[params.plausible]
enable = true
domain = "example.com"
启动步骤
- 确保已安装 Hugo。
- 在项目根目录下运行
hugo server
命令启动本地服务器。 - 访问
http://localhost:1313
查看项目运行情况。
3. 项目配置文件介绍
config.toml
config.toml
是项目的主要配置文件,包含了项目的各种配置选项。
主要配置项
- theme: 指定项目使用的主题,如
["plausible-hugo"]
。 - params.plausible: 配置 Plausible Analytics 的相关参数,如
enable
和domain
。
其他配置文件
- theme.yaml: 主题配置文件,用于定义主题的相关设置。
- go.mod: Go 模块文件,用于管理项目的依赖。
配置示例
theme = ["plausible-hugo"]
[params.plausible]
enable = true
domain = "example.com"
以上配置启用了 Plausible Analytics,并指定了域名为 example.com
。
通过以上步骤,您可以顺利启动并配置 Plausible-Hugo 项目。