Hugo 主题
Mainroad
Mainroad 是一个响应式、简洁且以内容为中心的 Hugo 主题。
Mainroad
Mainroad 是一个基于 MH Magazine lite 主题的响应式、简单、简洁且以内容为中心的 Hugo 主题。
演示 • 文档
功能
- 响应式设计
- 主菜单和辅助菜单
- 小部件化的侧边栏
- 翻译。超过 15 种语言,并且还在增加
- 可通过
config.toml
配置主题设置(侧边栏位置、作者框、文章导航、高亮颜色) - Hugo 内部模板(Open Graph、Schema、Twitter Cards、Disqus、Google Analytics)
- 广泛的跨浏览器兼容性
- 桌面端:IE11+、Chrome、Firefox、Safari
- 移动端:Android 浏览器(Android 4.4+)、Safari(iOS 7+)、Google Chrome、Opera mini
- 自定义 Google 字体支持、MathJax、目录、SVG 图标等等…
安装
在开始之前,请确保您已安装 Hugo 并创建了一个新站点。之后,您就可以安装 Mainroad 了。
从您的项目根目录运行
git clone https://github.com/vimux/mainroad.git themes/mainroad
或者,如果您不打算进行任何重大更改,但又想跟踪和更新主题,则可以使用以下命令将其添加为 git 子模块
git submodule add https://github.com/vimux/mainroad.git themes/mainroad
接下来,在 Hugo 站点的根目录中打开 config.toml
,并确保 theme 选项设置为 mainroad
theme = "mainroad"
配置
Config.toml 示例
baseurl = "/"
title = "Mainroad"
languageCode = "en-us"
paginate = "10" # Number of posts per page
theme = "mainroad"
disqusShortname = "" # DEPRECATED! Use .Services.Disqus.Shortname
googleAnalytics = "" # 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 authorbox
name = "John Doe"
bio = "John Doe's true identity is unknown. Maybe he is a successful blogger or writer. Nobody knows it."
avatar = "img/avatar.png"
[Params]
description = "John Doe's Personal blog about everything" # Site description. Used in meta description
copyright = "John Doe" # Footer copyright holder, otherwise will use site title
opengraph = true # Enable OpenGraph if true
schema = true # Enable Schema
twitter_cards = true # Enable Twitter Cards if true
readmore = false # Show "Read more" button in list if true
authorbox = true # Show authorbox at bottom of pages if true
toc = true # Enable Table of Contents
pager = true # Show pager navigation (prev/next links) at the bottom of pages if true
post_meta = ["author", "date", "categories", "translations"] # Order of post meta information
mainSections = ["post", "blog", "news"] # Specify section pages to show on home page and the "Recent articles" widget
dateformat = "2006-01-02" # Change the format of dates
mathjax = true # Enable MathJax
mathjaxPath = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js" # Specify MathJax path
mathjaxConfig = "TeX-AMS-MML_HTMLorMML" # Specify MathJax config
googleFontsLink = "https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700" # Load Google Fonts
customCSS = ["css/custom.css"] # Include custom CSS files
customJS = ["js/custom.js"] # Include custom JS files
# DEPRECATED PARAMS
subtitle = "" # Deprecated in favor of .Site.Params.logo.subtitle
highlightColor = "" # Deprecated in favor of .Site.Params.style.vars.highlightColor
[Params.style.vars]
highlightColor = "#e22d30" # Override highlight color
# Override font-family sets
# Take care of different quotes OR escaping symbols in these params if necessary
fontFamilyPrimary = "'Open Sans', Helvetica, Arial, sans-serif"
# Secondary font-family set responsible for pre, code, kbd, and samp tags font
fontFamilySecondary = "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace"
[Params.logo]
image = "img/placeholder.png" # Logo image. Path relative to "static"
title = "Mainroad" # Logo title, otherwise will use site title
subtitle = "Just another site" # Logo subtitle
[Params.thumbnail]
visibility = ["list", "post"] # Control thumbnail visibility
[Params.sidebar]
home = "right" # Configure layout for home page
list = "left" # Configure layout for list pages
single = false # Configure layout for single pages
# Enable widgets in given order
widgets = ["search", "recent", "categories", "taglist", "social", "languages"]
[Params.widgets]
recent_num = 5 # Set the number of articles in the "Recent articles" widget
categories_counter = false # Enable counter for each category in "Categories" widget
tags_counter = false # Enable counter for each tag in "Tags" widget
[Params.widgets.social]
cached = false # activate cache if true
# Enable parts of social widget
facebook = "username"
twitter = "username"
instagram = "username"
linkedin = "username"
telegram = "username"
github = "username"
gitlab = "username"
bitbucket = "username"
email = "[email protected]"
# Custom social links
[[Params.widgets.social.custom]]
title = "Youtube"
url = "https://youtube.com/user/username"
icon = "youtube.svg" # Optional. Path relative to "layouts/partials"
rel = "noopener noreferrer" # Set to false to remove the rel attribute
[[Params.widgets.social.custom]]
title = "My Home Page"
url = "https://example.com"
[Params.widgets.search]
cached = false # activate cache if true
url = "https://google.com/search"
[Params.widgets.search.input]
name = "sitesearch"
pre = ""
请勿直接复制示例配置。仅使用您需要的参数。
有关所有可用的标准配置设置的更多信息,请阅读所有 Hugo 配置设置。
Front Matter 示例
---
# Common-Defined params
title: "Example article title"
date: "2017-08-21"
description: "Example article description"
categories:
- "Category 1"
- "Category 2"
tags:
- "Test"
- "Another test"
menu: main # Optional, add page to a menu. Options: main, side, footer
# Theme-Defined params
thumbnail: "img/placeholder.png" # Thumbnail image
lead: "Example lead - highlighted near the title" # Lead text
comments: false # Enable Disqus comments for specific page
authorbox: true # Enable authorbox for specific page
pager: true # Enable pager navigation (prev/next) for specific page
toc: true # Enable Table of Contents for specific page
mathjax: true # Enable MathJax for specific page
sidebar: "right" # Enable sidebar (on the right side) per page
widgets: # Enable sidebar widgets in given order per page
- "search"
- "recent"
- "taglist"
---
有关所有可用的标准 Front Matter 变量的更多信息,请阅读 Hugo Front Matter。
贡献
您是否发现了错误或有新功能的想法?请随时使用问题跟踪器让我知道。或者直接发出拉取请求,但请遵守以下贡献指南。
许可证
此主题根据 GPLv2 许可证发布。