Hugo Clean White 主题配置指南

Hugo Clean White 主题配置要点

Tags: 

参考资料

exampleSite

  • git submodule add https://github.com/zhaohuabing/hugo-theme-cleanwhite.git themes/cleanwhite

  • config.yaml -> clean-white.yaml

  • hugo server

hugo server --disableFastRender -D --contentDir themes/cleanwhite/exampleSite/content --config clean-white.yaml

修复 Content Type 兼容性:post -> posts

Hugo content typefront matter.type(P0) 和 content 下对应的子目录(P1) 决定。^[content 根目录下的类型是 page]

找到锁死 content type 为 “post” 的模版

$ grep post\" themes/cleanwhite/layouts/* -r
themes/cleanwhite/layouts/_default/archive.html:{{ $pages := (where (where .Site.Pages "Type" "post") "IsPage" true) }}
themes/cleanwhite/layouts/partials/category.html:{{ $paginator := .Paginate (where .Data.Pages "Section" "post") }}
themes/cleanwhite/layouts/partials/portfolio.html:{{ $paginator := .Paginate (where (where .Site.Pages "Type" "post") "IsPage" true) }}

Search 无效问题 themes/cleanwhite/static/js/jquery.js

适配菜单

  • 🔍
  • ARCHIVE content/menu/archive: type: archive
params:
  ...
  addtional_menus:
    - title: ARCHIVE
      href: /menu/archive/

替换搜索工具

params:
  ...
  algolia_search: false
  1. layouts/_default/search.html
  2. layouts/_default/index.json

替换默认字体

static/css/hugo-theme-cleanwhite.min.css

@import url('https://npm.elemecdn.com/lxgw-wenkai-screen-webfont/style.css');

body {
  font-family: "LXGW WenKai Screen", sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "LXGW WenKai Screen", "raleway", sans-serif;
  margin: 0;
  padding: 0;
  font-weight: 400;
}

cp static/css/hugo-theme-cleanwhite.min.css public/css

头图

params:
  ...
  header_image: /photos/202403171612965.png
  sidebar_avatar: /photos/202403191629989.png
Last updated on 2024-08-14 10:11
Built with Hugo