跳至主要內容

Hugo + HBstart 主题构建导航页

诗往哥2024年12月25日建站hugo导航页约 1111 字大约 4 分钟

安装 HBstart 主题

相关信息

HB start 主题

示例平台:Windows 10。先用 Chocolatey 安装 GoDart SassHugoGitNode.js 。建议尽可能使用这些工具的最新版本。

温馨提示

本文默认你是配置环境变量的熟手,如果你没有相关的经验,请从Chocolatey开始。

克隆仓库

git clone --depth 1 https://github.com/hbstack/theme-start

复制 Example Site

cp -r theme-start/exampleSite ./start-page

更改工作目录

cd start-page

重新初始化站点

rm go.mod go.sum config/_default/module.yaml
hugo mod init github.com/user/repo

导入主题和搜索引擎

目录:config/_default

toml

文件名:module.toml

[[imports]]
  path = 'github.com/hbstack/theme-start'
[[imports]]
  path = 'github.com/hbstack/theme-start/engines/google'
[[imports]]
  path = 'github.com/hbstack/theme-start/engines/bing'

安装依赖项

npm ci

启动 Hugo 服务器

hugo server

自定义搜索引擎

搜索引擎属性

名字类型描述
weightnumber较低的权重获得更高的优先级。

内置搜索引擎

名字标识符模块
百度baidugithub.com/hbstack/theme-start/engines/baidu
必应binggithub.com/hbstack/theme-start/engines/bing
一只叛逆的鸭子duckduckgogithub.com/hbstack/theme-start/engines/duckduckgo
谷歌googlegithub.com/hbstack/theme-start/engines/google
搜狗sogougithub.com/hbstack/theme-start/engines/sogou
维基百科wikipediagithub.com/hbstack/theme-start/engines/wikipedia
雅虎yahoogithub.com/hbstack/theme-start/engines/yahoo
Yandexyandexgithub.com/hbstack/theme-start/engines/yandex

搜索引擎配置

目录:config/_default

toml

文件名:hugo.toml

[module]
  [[module.imports]]
    path = 'github.com/hbstack/theme-start/engines/google'
  [[module.imports]]
    path = 'github.com/hbstack/theme-start/engines/bing'
  [[module.imports]]
    path = 'github.com/hbstack/theme-start/engines/baidu'
  [[module.imports]]
    path = 'github.com/hbstack/theme-start/engines/duckduckgo'
[params]
  [params.hb]
    [params.hb.theme_start]
      [params.hb.theme_start.search_engines]
        [params.hb.theme_start.search_engines.baidu]
          weight = 3
        [params.hb.theme_start.search_engines.bing]
          weight = 2
        [params.hb.theme_start.search_engines.duckduckgo]
          weight = 4
        [params.hb.theme_start.search_engines.google]
          weight = 1

调整 HB start 主题外观

背景图像

把背景图像保存为:background.*(目前支持webp/png/jpg),粘贴到目录 assets/images 里面。

Favicons

把 logo 图像保存为:logo.png,粘贴到目录 assets/images 里面。

管理应用程序

toml

文件名:menus.toml

[[apps]]
  identifier = 'group-1'
  name = 'Group 1'
[[apps]]
  name = 'Foo'
  parent = 'group-1'
  url = 'https://example.org/foo'
[[apps]]
  identifier = 'group-2'
  name = 'Group 2'
[[apps]]
  name = 'Bar'
  parent = 'group-2'
  url = 'https://example.org/bar'
apps:
  - identifier: group-1
    name: Group 1
  - name: Foo
    parent: group-1
    url: https://example.org/foo
    weight: 1
    params:
      icon:
        vendor: simple
        name: bilibili
vendorname
font-awesome-brandsbilibili
simple-iconsbilibili
tabler'outline/brand-bilibili'

注意

outline/brand-bilibili要加英文单引号或双引号后,才能在 YAML 中起作用。

设置 HB start 主题简繁英

相关信息

推送到 GitHub

git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/user/repo.git
git push -u origin main
#同步仓库
git pull origin main

#再修改/添加,并添加修改/新文件
git add .

#然后提交
git commit -m '描述'

#最后推送
git push origin main

部署

通过 Cloudflare Pages 部署站点

  1. 登录 Cloudflare
  2. 下拉找到 Workers 和 Pages,单击创建,选 Pages ,再点连接到Git
  3. 根据提示选择好Git存储库
  4. 设置构建配置。
    • 构建命令:npm ci && hugo
    • 构建输出:public
  5. 环境变量。
    • HUGO_VERSION:Hugo版本号如0.111.3
    • NODE_VERSION:Node.js版本号大于 16 就可以,如 19
    • EMBEDDED_DART_SASS_VERSION:Dart Sass版本号如 1.62.1

相关信息

Your primary language is en-US, do you want to switch to it?

您的首选语言是 en-US,是否切换到该语言?