漢堡是 Hugo 的一個簡單乾淨的部落格主題,基於 keichi 的維也納主題。
我會告訴別人的顯著特徵是:
在您的hugo網站目錄中,運行:
git clone https://github.com/hauke96/hugo-theme-hamburg.git themes/hamburg
主題現在應該位於themes/hamburg/
中。
您可以在網站的config.toml
(或config.yaml
/ config.json
)中指定以下選項以使用此主題的功能:
baseurl = " http://your-site.com "
defaultContentLanguage = " en "
defaultContentLanguageInSubdir = " true "
title = " Your site title "
theme = " hamburg "
[ params ]
# Short subtitle/tagline. This is displayed in the header.
themecolor = " #hexcolor " # Defines the tab color in Chrome for Android.
# To load additional CSS styles
customCSS = [ ' hamburg.css ' ]
# Show this very user-friendly and absolutely not annoying GDPR notice at the bottom of the page
ShowGDPRNotice = true
subtitle = " The great example site of the hugo-hamburg-theme "
# Since 0.57.0 there's the concept of "main sections". The files for the section "posts" are in "./content/posts/".
mainSections = [ " posts " ]
[ languages ]
[ languages . en ]
languageCode = " en "
languageName = " English "
subtitle = " A simple subtitle "
# Copyright notice. This is displayer in the footer.
copyright = " © some license "
[ languages . en . menu ]
[[ languages . en . menu . main ]]
name = " About "
identifier = " about "
url = " pages/about "
[ languages . de ]
languageCode = " de "
languageName = " Deutsch "
subtitle = " Ein einfacher Untertitel "
copyright = " © eine Lizenz "
[ languages . de . menu ]
[[ languages . de . menu . main ]]
name = " Über "
identifier = " about "
url = " pages/about "
vienna
主題參數到目前為止,我還沒有使用原始維也納主題中的一些其他參數。其中大多數可能不再起作用,因此不能保證:
[ params ]
# Social accounts. Link to these accounts are displayed in the header and
# footer.
twitter = " Your Twitter username "
github = " Your GitHub username "
gitlab = " Your GitLab username "
linkedin = " Your LinkedIn username "
googleplus = " Your Google+ user id "
facebook = " Your Facebook username "
reddit = " Your Reddit username "
hackernews = " Your Hacker News username "
stackoverflow = " Your Stackoverflow user id (number) "
keybase = " Your keybase.io username "
instagram = " Your Instagram username "
# Disqus shortname
disqus = " Your disqus shortname "
# Google Analytics API key.
ga_api_key = " Your Google Analytics tracking id "
# Mixpanel API key.
mixpanel_api_key = " Your Mixpanel API key "
您可以在貼文或頁面的標題中設定一些選項:
# The date will be at the bottom of the page at the "Posted on ..." label
date = " 2018-08-13T15:38:27+02:00 "
title = " Erster Eintrag "
draft = true
author = " hauke "
# The summary will be shown at the start page or other page/post lists
summary = " Dies ist nur ein Testbeitrag um die Website zu testen. "
# This will ensure that the date is not printed
noshowdate = true
有一些簡單的短代碼可以讓事情變得更容易。
建立一個指向標籤頁的簡單連結:
I like {{< linkTag veggy-food "yummi vegetarian food" >}}.
包含圖像並在單擊時在新選項卡中打開它們:
{{< img "photo.png" "What a lovely picture" >}}
創建到給定圖像的鏈接
{{< imgUrl "photo.png" "link text" >}}
將圖像縮放到給定大小並像簡碼img
一樣嵌入它。
{{< imgUrl "photo.png" "What a lovely picture" "500x" >}}
(此影像寬度縮放為 500 像素,高度自動確定)
該主題將根據頁面的語言代碼讀取作者的信息。
若要支援多個作者,請建立data/<lang>/authors/name.toml
檔案(例如data/en/authors/hauke96.toml
)。該文件包含有關作者的資訊:
name = " Your name "
avatar = " /images/avatar.jpg "
contact = " mailto:[email protected] "
bio = " Something about you "
若要支援多種語言,請在data
目錄中建立多個目錄。因此,對於德語作為第二語言( languageCode
將是de
),上面的範例還將有一個data/de/authors/hauke96.toml
檔案。
您可以將上述配置與 Google Analytics 等一起使用,或使用您自己的 JavaScript 片段來執行此操作。
對於自訂 JavaScript 程式碼片段,您必須建立一個layouts/partials/tracking.html
檔案並將必要的程式碼放入該檔案中。該文件(如果存在)將嵌入到其他追蹤機制旁邊的頁腳中。
我使用 Matomo 分析軟體對此進行了測試,該軟體提供了一個 JavaScript 或基於圖像的片段,我將其放入tracking.html
中。