Hugo 使用 config.toml、config.yaml 或 config.json(如果在站点根目录中找到)作为默认的站点配置文件。以下是 Binario 的 TOML 配置示例,其中包含所有可用的主题特定配置参数
Config.toml 示例
baseurl = "/"title = "Binario"languageCode = "en-us"paginate = "10"# Number of elements per page in paginationtheme = "binario"disqusShortname = ""# DEPRECATED! Use .Services.Disqus.ShortnamegoogleAnalytics = ""# DEPRECATED! Use .Services.googleAnalytics.ID[services.disqus]
shortname = ""# Enable Disqus by entering your Disqus shortname[services.googleAnalytics]
ID = ""# Enable Google Analytics by entering your tracking ID[Author] # Used in authorboxname = "John Doe"bio = "John Doe's true identity is unknown. Maybe he is a successful blogger or writer."avatar = "img/avatar.png"[Params]
description = "Responsive card-based & code-light Hugo theme"# Site Description. Used in meta descriptioncopyright = "Binario"# Copyright holder, otherwise will use .Site.Titleopengraph = true# Enable OpenGraph if trueschema = true# Enable Schematwitter_cards = true# Enable Twitter Cards if truecolumns = 2# Set the number of cards columns. Possible values: 1, 2, 3mainSections = ["post"] # Set main page sectionsdateFormat = "January 02, 2006"# Change the format of datescolorTheme = ""# dark-green, dark-blue, dark-red, dark-violetcustomCSS = ["css/custom.css"] # Include custom CSS filescustomJS = ["js/custom.js"] # Include custom JS filesmainMenuAlignment = "right"# Align main menu (desktop version) to the right sideauthorbox = true# Show authorbox at bottom of single pages if truecomments = true# Enable comments for all site pagesrelated = true# Enable Related content for single pagesrelatedMax = 5# Set the maximum number of elements that can be displayed in related block. Optionalmathjax = true# Enable MathJax for all site pagesmathjaxPath = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js"# Specify MathJax path. OptionalmathjaxConfig = "TeX-AMS-MML_HTMLorMML"# Specify MathJax config. OptionalhideNoPostsWarning = false# Don't show no posts empty state warning in main page, if true[Params.Entry]
meta = ["date", "categories", "tags"] # Enable meta fields in given ordertoc = true# Enable Table of ContentstocOpen = true# Open Table of Contents block. Optional[Params.Featured]
previewOnly = false# Show only preview featured image[Params.Breadcrumb]
enable = true# Enable breadcrumb block globallyhomeText = "Binario"# Home node text[Params.Social]
email = "[email protected]"facebook = "username"twitter = "username"telegram = "username"instagram = "username"pinterest = "username"vk = "username"linkedin = "username"github = "username"gitlab = "username"stackoverflow = "numberid"mastodon = "https://some.instance/@username"medium = "username"[Params.Share] # Entry Share blockfacebook = truetwitter = truereddit = truetelegram = truelinkedin = truevk = truepocket = truepinterest = true# Web App Manifest settings# https://www.w3.org/TR/appmanifest/# https://developers.google.com/web/fundamentals/web-app-manifest/[Params.Manifest]
name = "Binario"shortName = "Binario"display = "browser"startUrl = "/"backgroundColor = "#2a2a2a"themeColor = "#1b1b1b"description = "Responsive card-based & code-light Hugo theme"orientation = "portrait"scope = "/"[outputFormats]
[outputFormats.MANIFEST]
mediaType = "application/json"baseName = "manifest"isPlainText = truenotAlternative = true[outputs]
home = ["HTML", "RSS", "MANIFEST"]
有关 Hugo 配置文件的更多信息以及所有常见的配置设置,请阅读 Hugo 官方文档中的“配置 Hugo”。
Front Matter 示例
Hugo 支持三种 Front Matter 格式:yaml、toml 和 json。以下是 YAML 格式的 Front Matter 示例
---
# Common-Defined paramstitle: "Example article title"date: "2017-08-21"lastmod: "2018-12-21"description: "Example article description"categories:
- "Category 1" - "Category 2"tags:
- "Tag" - "Another tag"menu: main # Add page to a menu. Options: main, footer# Theme-Defined paramscomments: true# Enable/disable Disqus comments for specific pageauthorbox: true# Enable/disable Authorbox for specific pagetoc: true# Enable/disable Table of Contents for specific pagetocOpen: true# Open Table of Contents block for specific pagemathjax: true# Enable/disable MathJax for specific pagerelated: true# Enable/disable Related content for specific pagemeta:
- date - categories - tagsfeatured:
url: image.jpg# relative path of the imagealt: A scale model of the Eiffel tower# alternate text for the imagecaption: Eiffel tower model# image captioncredit: Unknown author# image creditpreviewOnly: false# show only preview image (true/false)---
有关 Front Matter 变量和格式的更多信息,请阅读 Hugo 官方文档中的“Hugo Front Matter”。