HUGO設定檔

分享一下這網頁的設定

config.yml

baseURL: https://xavierzheng.github.io
languageCode: zh-tw
title: Biology and computer science
theme: PaperMod

enableRobotsTXT: true
buildDrafts: false
buildFuture: false
buildExpired: false

minify:
  disableXML: true
  minifyOutput: true

params:
  env: production # to enable google analytics, opengraph, twitter-cards and schema.
  title: Biology and computer science
  keywords: [Blog]
  author: Me
  images: ["<link or path of image for opengraph, twitter-cards>"]
  defaultTheme: auto # dark, light
  disableThemeToggle: false

  ShowReadingTime: false
  ShowShareButtons: false
  ShowPostNavLinks: true
  ShowBreadCrumbs: true
  ShowCodeCopyButtons: true
  ShowWordCount: false
  ShowRssButtonInSectionTermList: false
  UseHugoToc: true
  disableSpecial1stPost: false
  disableScrollToTop: false
  comments: false
  hidemeta: false
  hideSummary: false
  showtoc: true
  tocopen: true

  assets:
    # disableHLJS: true # to disable highlight.js
    # disableFingerprinting: true
    favicon: "<link / abs url>"
    favicon16x16: "<link / abs url>"
    favicon32x32: "<link / abs url>"
    apple_touch_icon: "<link / abs url>"
    safari_pinned_tab: "<link / abs url>"

  label:
    text: "Biology and computer science"
    icon: /apple-touch-icon.png
    iconHeight: 35

  # profile-mode
  profileMode:
    enabled: false # needs to be explicitly set
    title: Biology and computer science
    subtitle: "Things related to my jobs"
    imageUrl: "<img location>"
    imageWidth: 120
    imageHeight: 120
    imageTitle: my image
    buttons:
      - name: Posts
        url: posts
      - name: Tags
        url: tags

  cover:
    hidden: true # hide everywhere but not in structured data
    hiddenInList: true # hide on list pages and home
    hiddenInSingle: true # hide on single page

  # for search
  # https://fusejs.io/api/options.html
  fuseOpts:
    isCaseSensitive: false
    shouldSort: true
    location: 0
    distance: 1000
    threshold: 0.4
    minMatchCharLength: 0
    keys: ["title", "permalink", "summary", "content"]

menu:
  main:
    - identifier: search
      name: search
      url: search
      weight: 10
    - identifier: tags
      name: tags
      url: /tags/
      weight: 20
    - identifier: archives
      name: archives
      url: /archives/
      weight: 30

outputs:
  home:
    - HTML
    - RSS
    - JSON

archetypes/post.md

---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
# weight: 1
# aliases: ["/first"]
tags: ["first"]
author: "Me"
description: ""
summary: ""
# author: ["Me", "You"] # multiple authors
showToc: true
TocOpen: true
draft: false
hidemeta: false
comments: false
canonicalURL: "https://canonical.url/to/page"
disableHLJS: false # to disable highlightjs
disableShare: true
disableHLJS: false
hideSummary: false
searchHidden: false
ShowReadingTime: false
ShowBreadCrumbs: true
ShowPostNavLinks: true
ShowWordCount: false
ShowRssButtonInSectionTermList: true
UseHugoToc: true
cover:
    image: "<image path/url>" # image path/url
    alt: "<alt text>" # alt text
    caption: "<text>" # display caption under cover
    relative: false # when using page bundles set this to true
    hidden: true # only hide on current single page
---

在content資料夾建立search.md

裡面要寫上

---
title: "Search" # in any language you want
layout: "search" # is necessary
summary: "search"
placeholder: "placeholder text in search input box"
---
params:
    fuseOpts:
        isCaseSensitive: false
        shouldSort: true
        location: 0
        distance: 1000
        threshold: 0.4
        minMatchCharLength: 0
        keys: ["title", "permalink", "summary", "content"]

確定post.md裡面是 searchHidden: false

某些預設的config是 searchHidden: true ,記得要改

記得要去改 themes/PaperMod/assets/js/fastsearch.js

  // xhr.open('GET', "../index.json");  不要用這個,改成下面那個
  xhr.open('GET', "https://xavierzheng.github.io/index.json");

Enable archive

記得加上 archives.md 在 content 資料夾,裡面寫

---
title: "Archive"
layout: "archives"
url: "/archives/"
summary: archives
---