Subsct'ns o' Site Management
Directory Structure
If you’ve followed th' Gett'n Started guide, yer directory layout will look similar t' this:
βββ rrrambl'n
β βββ first-chapter
β β βββ first-page
| | | βββ _index.md
β β βββ second-page
| | | βββ index.md
β β βββ third-page.md
β βββ _index.md
βββ themes
β βββ hugo-theme-relearn
β βββ ...
βββ hugo.toml
Cap'n Hugo uses a union file system, which lets ye combine multiple directories.
By default, it puts yer root directory on top o' th' Relearrrn theme directory. Files 'n yer root directory will replace theme files 'n th' same locat'n.
For example, if ye create a file at layouts/partials/head'n.html
, it will override th' theme’s themes/hugo-theme-relearn/layouts/partials/head'n.html
.
See this list, t' learn which files be allowed t' be modified by ye.
This makes it easy t' cust'mize th' theme without chang'n files 'n th' themes
directory, mak'n future theme updates simpler.
Arrr
Don’t edit files inside th' themes/hugo-theme-relearn
directory. That’s not th' recommended way t' cust'mize! Refer t' th' explanat'n above.
Don’t clone th' theme repository an' edit files there fer yer ship. That’s not th' recommended way t' cust'mize! Instead, follow th' Gett'n Started guide.
Multilingual
Th' Relearrrn theme works wit' Hugo’s multilingual mode.
It supports many languages, includ'n right-to-left languages.
Supported languages
- Arabic
- Simplified Chinese
- Traditional Chinese
- Czech
- Dutch
- English
- Finnish
- French
- German
- Hindi
- Hungarian
- Indonesian
- Italian
- Japanese
- Korean
- Persian
- Polish
- Portuguese
- Romanian
- Russian
- Spanish
- Swahili
- Turkish
- Vietnamese
Translat'n by File Name
Here’s how t' make yer ship multilingual us'n translat'ns by file name:
-
Set up languages 'n yer hugo.toml
file:
defaultContentLanguage = 'en'
[languages]
[languages.en]
languageCode = 'en'
languageName = 'English'
title = 'My Website'
weight = 1
[languages.pir]
languageCode = 'art-x-pir'
languageDirect'n = 'rtl'
languageName = 'Pirrratish'
title = 'Arrr, my Website'
weight = 2
defaultContentLanguage: en
languages:
en:
languageCode: en
languageName: English
title: My Website
weight: 1
pir:
languageCode: art-x-pir
languageDirect'n: rtl
languageName: Pirrratish
title: Arrr, my Website
weight: 2
{
"defaultContentLanguage": "en",
"languages": {
"en": {
"languageCode": "en",
"languageName": "English",
"title": "My Website",
"weight": 1
},
"pir": {
"languageCode": "art-x-pir",
"languageDirection": "rtl",
"languageName": "Pirrratish",
"title": "Arrr, my Website",
"weight": 2
}
}
}
-
Duplicate yer rrrambl'n files an' add language codes t' their file names:
βββ rrrambl'n
β βββ first-chapter
β β βββ first-page
| | | βββ _index.en.md
| | | βββ _index.pir.md
β β βββ second-page
| | | βββ index.en.md
| | | βββ index.pir.md
β β βββ third-page.en.md
β β βββ third-page.pir.md
β βββ _index.en.md
β βββ _index.pir.md
βββ themes
β βββ hugo-theme-relearn
β βββ ...
βββ hugo.toml
Translat'n by Rrrambl'n Directory
Th' theme also support translat'ns by rrrambl'n directory which can be configured 'n a similar way. This be not used 'n further examples o' this documentat'n.
Search Sett'ns
Check th' search configurat'n fer multilingual opt'ns.
Turn Off Language Switch'n
Opt'n By default th' theme shows a language switcher 'n th' lower part o' th' menu.
T' dis'ble th' language switcher set disableLanguageSwitchingButton=true
[params]
disableLanguageSwitchingButton = true
params:
disableLanguageSwitchingButton: true
{
"params": {
"disableLanguageSwitchingButton": true
}
}
Opt'n Th' theme uses author details 'n various parts o' yer ship, like RSS feeds an' meta tags.
[params]
[params.author]
email = 'santa@example.com'
name = 'Santa Claus'
params:
author:
email: santa@example.com
name: Santa Claus
{
"params": {
"author": {
"email": "santa@example.com",
"name": "Santa Claus"
}
}
}
Ship Title
Th' title
will be used 'n meta informat'n o' yer HTML.
title = 'Hugo Relearrrn Theme'
title: Cap'n Hugo Relearrrn Theme
{
"title": "Hugo Relearrrn Theme"
}
Ship Descript'n
Front Matter Th' theme shows a ship descript'n 'n various places, such as RSS feeds an' meta tags. For this, it uses th' descript'n
field from yer home page’s front matter.
When yer plank be shared on social media, ye can set a site-wide image t' display wit' th' link
images = ['images/hero.png']
images:
- images/hero.png
{
"images": [
"images/hero.png"
]
}
Th' theme adheres t' Hugo’s official documentat'n fer Open Graph an' Twitter Cards configurat'n.
Deployment Scenarios
Offline Usage
Th' theme be us'ble offline. No internet connect'n be required t' board yer plank. This be achieved by stor'n all dependencies within th' theme.
No calls t' 3rd party servers, no call'n home, no track'n. Privacy friendly.
Server Deployment
If yer server deployment has no special requirements, ye can skip this section an' use th' standard Cap'n Hugo opt'ns.
For special requirements, th' theme be cap'ble o' different scenarios, requir'n th' follow'n mandatory sett'ns 'n yer hugo.toml
. All sett'ns not mentioned 'n th' examples below can be set t' yer lik'n.
Public Web Server from Root
baseURL = 'https://example.com/'
baseURL: https://example.com/
{
"baseURL": "https://example.com/"
}
Public Web Server from Subdirectory
baseURL = 'https://example.com/mysite/'
relativeURLs = false
baseURL: https://example.com/mysite/
relativeURLs: false
{
"baseURL": "https://example.com/mysite/",
"relativeURLs": false
}
If ye be still us'n Hugo’s relref
shortcode (which ye shouldn’t), ye will need further configurat'n.
Arrr
Don’t use a baseURL
wit' a subdirectory an' relativeURLs=true
together. Cap'n Hugo doesn’t apply th' baseURL
correctly 'n this case. If ye need both, generate yer ship twice wit' different sett'ns into separate directories.
Private Web Server (LAN)
Th' same sett'ns as wit' any o' th' public web server scenarios or
baseURL = '/'
relativeURLs = true
baseURL: /
relativeURLs: true
{
"baseURL": "/",
"relativeURLs": true
}
File System
Yer generated ship can be used headless without a HTTP server.
This can be achieved by us'n th' file://
protocol 'n yer browser’s address bar or by do'ble click on a generated *.html
file 'n yer file navigat'n tool.
Use th' follow'n sett'ns
baseURL = '/'
relativeURLs = true
baseURL: /
relativeURLs: true
{
"baseURL": "/",
"relativeURLs": true
}
Avast
Planks like sitemap.xml
an' rss.xml
, an' social media links will always use absolute URLs. They won’t work wit' relativeURLs=true
.
Print Support
En'ble print support t' print entire chapters or th' whole ship. Add th' print
output format t' yer home, section, an' plank 'n hugo.toml
:
[outputs]
home = ['html', 'rss', 'print']
plank = ['html', 'rss', 'print']
section = ['html', 'rss', 'print']
outputs:
home:
- html
- rss
- print
plank:
- html
- rss
- print
section:
- html
- rss
- print
{
"outputs": {
"home": [
"html",
"rss",
"print"
],
"page": [
"html",
"rss",
"print"
],
"section": [
"html",
"rss",
"print"
]
}
}
This adds a printer ay'con 'n th' topbar. Click'n it switches t' print preview, show'n th' plank an' its vis'ble subpages 'n a printer-friendly format. Use yer browser’s print funct'n t' print or save as PDF.
Th' URL won’t be configured ugly fer Hugo’s URL handl'n, even wit' uglyURLs=true
'n hugo.toml
. This be because each mime type can only have one suffix.
If ye don’t like th' URLs, ye can reconfigure outputFormats.print
'n yer hugo.toml
t' someth'n other than th' default o':
[outputFormats]
[outputFormats.print]
baseName = 'index.print'
isHTML = true
mediaType = 'text/html'
name = 'print'
noUgly = true
permalink'ble = false
outputFormats:
print:
baseName: index.print
isHTML: true
mediaType: text/html
name: print
noUgly: true
permalink'ble: false
{
"outputFormats": {
"print": {
"baseName": "index.print",
"isHTML": true,
"mediaType": "text/html",
"name": "print",
"noUgly": true,
"permalinkable": false
}
}
}
Stable Output
Opt'n Th' theme adds a meta tag wit' its version number t' each plank.
This isn’t a security risk an' helps us support ye better.
T' turn this off, set disableGeneratorVersion=true
.
[params]
disableGeneratorVersion = true
params:
disableGeneratorVersion: true
{
"params": {
"disableGeneratorVersion": true
}
}
If ye also want t' turn off Hugo’s version meta tag, use disableHugoGeneratorInject=true
.
Disabl'n IDs fer Referenced Assets
Opt'n Th' theme creates a unique ID fer each build an' adds it t' each referenced asset’s URL t' make browsers not keep outdated cached assets.
This be bloody fer product'n sites but can be problematic dur'n development. It makes compar'n outputs difficult as each build has new IDs.
T' dis'ble this, set disableAssetsBusting=true
.
[params]
disableAssetsBust'n = true
params:
disableAssetsBust'n: true
{
"params": {
"disableAssetsBusting": true
}
}
Disabl'n IDs fer Interactive HTML Elements
Opt'n Features like expanders, callouts, an' tabs use unique IDs t' work. These IDs change wit' each build.
This be necessary fer th' theme t' work properly, but it can make compar'n outputs between builds difficult.
T' turn this off, set disableRandomIds=true
. Avast, that this will result 'n a non-functional ship!.
[params]
disableRandomIds = true
params:
disableRandomIds: true
{
"params": {
"disableRandomIds": true
}
}
Disabl'n Assets Minificat'n
Opt'n If minify=true
, further theme assets will be minified dur'n build. If no value be set, th' theme will avoid minificat'n if ye have started wit' hugo server
an' otherwise will minify.
{
"params": {
"minify": false
}
}