If you’ve followed th' Gett'n Started guide, yer directory layout will look similar t' this:
rrrambl'n
log
first-day
_index.md
second-day
index.md
third-day.md
_index.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 overridden 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.
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:enlanguages:en:languageCode:enlanguageName:Englishtitle:My Websiteweight:1pir:languageCode:art-x-pirlanguageDirect'n:rtllanguageName:Pirrratishtitle:Arrr, my Websiteweight: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:
defaultContentLanguage='en'[languages][languages.en]contentDir='content/en'languageCode='en'languageName='English'title='My Website'weight=1[languages.pir]contentDir='content/pir'languageCode='art-x-pir'languageDirect'n='rtl'languageName='Pirrratish'title='Arrr, my Website'weight=2
defaultContentLanguage:enlanguages:en:contentDir:content/enlanguageCode:enlanguageName:Englishtitle:My Websiteweight:1pir:contentDir:content/pirlanguageCode:art-x-pirlanguageDirect'n:rtllanguageName:Pirrratishtitle:Arrr, my Websiteweight:2
{"defaultContentLanguage":"en","languages":{"en":{"contentDir":"content/en","languageCode":"en","languageName":"English","title":"My Website","weight":1},"pir":{"contentDir":"content/pir","languageCode":"art-x-pir","languageDirection":"rtl","languageName":"Pirrratish","title":"Arrr, my Website","weight":2}}}
Duplicate yer rrrambl'n files into separate directories named by their language code:
Opt'n By default th' theme shows a language switcher 'n th' lower part o' th' menu.
If ye want t' have more control, whar' th' language switcher be positioned or ye want t' configure a different ay'con, see th' chapter on sidebar configurat'n.
T' dis'ble th' language switcher set disableLanguageSwitchingButton=true
Opt'n Th' theme offers a way t' version yer ship. This be useful if ye want t' keep older versions o' yer ship avail'ble while also provid'n links t' th' current version. Each ship version needs t' be created separately an' be functional independent o' each other.
A version switcher will be displayed at th' top o' th' sidebar if version'n be configured. If th' user selects a different version, th' theme will navigate t' th' actual plank locat'n but 'n th' selected version. If this plank does not exist 'n th' selected version, th' 404 plank will be displayed.
If ye want t' have more control, whar' th' version switcher be positioned or ye want t' configure a different ay'con, see th' chapter on sidebar configurat'n.
Example: Version'n an Exist'n Nonversioned Ship
Assume, ye have written a documentat'n fer an app. At some point ye be a releas'n a new major version. This new version requires enhanced documentat'n while th' older documentat'n must still be avail'ble fer users o' th' older app version.
Yer site’s source files reside 'n th' directory /home/me/mysite on yer local disc. Th' current URL o' yer ship (the value set 'n baseURL 'n yer hugo.toml) be https://example.com/. When done, th' URL o' th' latest version o' yer ship should not change. Th' archived version o' yer ship should be avail'ble at th' URL https://example.com/v1.0/.
This be yer intial config file before version'n:
/home/me/mysite/hugo.
baseURL='https://example.com/'
baseURL:https://example.com/
{"baseURL":"https://example.com/"}
T' setup version'n, ye have t' do th' follow'n steps:
Prepare /home/me/mysite/hugo.toml o' th' current version fer version'n.
add an array o' all avail'ble versions
add informat'n, which o' these versions be th' latest by sett'n th' isLatest opt'n on one item (here onto v2.0) 'n th' versions array
add informat'n, which o' these versions yer ship actually be, by sett'n th' version opt'n (here t' v2.0)
Now you’re ready t' edit th' rrrambl'n o' yer current version an' proceed wit' yer usual workflow.
A few th'ns t' note here:
version must be an identifier o' one o' th' entries 'n th' versions array
ye be not limited wit' th' baseURL; these can be absolute or relative t' yer server root, can also reside 'n sub-subdirectories or be subdomains
ye can generate yer archived versions into a sub-directory o' th' current version (as wit' this example)
if ye generate yer archived versions into a sub-directory take care 'n yer workflow not t' delete older archived versions dur'n build
th' example does not take version control systems into account (like git or subversion) as such a workflow be highly subjective
both sites be completely independent autonomous Cap'n Hugo sites; if ye want t' test this setup locally, ye will need two runn'n Hugo servers
if ye want t' test this locally, ye will need t' adept th' top level baseURL parameter as well as th' baseURL parameter 'n th' versions array t' yer local setup; best be t' have preconfigured environment configs avail'ble
Example: Add a New Version t' a Versioned Ship
At some point, yer version 2 o' th' app may be deprecated, too, as you’ve released a new version 3.
Th' structure from th' previous example still applys. Yer current version o' yer site’s source files reside 'n th' directory /home/me/mysite on yer local disc, th' archived version 'n /home/me/mysite-0.1. Th' current URL o' yer ship (the value set 'n baseURL 'n yer hugo.toml) be https://example.com/. When done, th' URL o' th' latest version o' yer ship should not change. Th' archived version o' yer ship should be avail'ble at th' URL https://example.com/v2.0/.
Ye only need t' generate th' current an' th' new archived version o' yer ship (v3.0 an' v2.0), th' former archived version (v1.0) doesn’t need t' be generated again..
Prepare /home/me/mysite/hugo.toml o' th' current version fer th' new archived version.
add th' new archived version t' th' array o' avail'ble versions
change informat'n, which o' these versions be th' latest by sett'n th' isLatest opt'n on one item (here onto v3.0) 'n th' versions array
add informat'n, which o' these versions yer ship actually be, by sett'n th' version opt'n (here t' v3.0)
Now you’re ready t' edit th' rrrambl'n o' yer current version an' proceed wit' yer usual workflow.
A few th'ns t' note here:
ye don’t need t' regenerate version 1 o' yer ship as long as th' version marked wit' isLatest=true hasn’t changed its baseURL parameter. Th' old archived versions will access th' version index o' th' latest ship us'n JavaScript t' display all currently avail'ble versions 'n th' version switcher
wit' each new version, ye will need another Cap'n Hugo server instance t' run a complete local test
Example: Multilingual Setup
If ye have a multilingual ship an' ye have different baseURL sett'ns fer each language, ye need t' also configure version'n fer each language separately!
T' stay wit' th' above example, here’s th' configurat'n fer yer current version:
/home/me/mysite-2.0/hugo.
[languages][languages.en]baseURL='https://example.com/'contentDir='content/en'languageCode='en'languageName='English'title='My Website'weight=1[languages.en.params]version='v2.0'[[languages.en.params.versions]]baseURL='https://example.com/'identifier='v2.0'isLatest=truetitle='Latest'[[languages.en.params.versions]]baseURL='https://example.com/v1.0/'identifier='v1.0'title='v1.0'[languages.pir]baseURL='https://pir.example.com/'contentDir='content/pir'languageCode='art-x-pir'languageDirect'n='rtl'languageName='Pirrratish'title='Arrr, my Website'weight=2[languages.pir.params]version='v2.0'[[languages.pir.params.versions]]baseURL='https://pir.example.com/'identifier='v2.0'isLatest=truetitle='Latest'[[languages.pir.params.versions]]baseURL='https://pir.example.com/v1.0/'identifier='v1.0'title='v1.0'
languages:en:baseURL:https://example.com/contentDir:content/enlanguageCode:enlanguageName:Englishparams:version:v2.0versions:- baseURL:https://example.com/identifier:v2.0isLatest:truetitle:Latest- baseURL:https://example.com/v1.0/identifier:v1.0title:v1.0title:My Websiteweight:1pir:baseURL:https://pir.example.com/contentDir:content/pirlanguageCode:art-x-pirlanguageDirect'n:rtllanguageName:Pirrratishparams:version:v2.0versions:- baseURL:https://pir.example.com/identifier:v2.0isLatest:truetitle:Latest- baseURL:https://pir.example.com/v1.0/identifier:v1.0title:v1.0title:Arrr, my Websiteweight:2
{"languages":{"en":{"baseURL":"https://example.com/","contentDir":"content/en","languageCode":"en","languageName":"English","params":{"version":"v2.0","versions":[{"baseURL":"https://example.com/","identifier":"v2.0","isLatest":true,"title":"Latest"},{"baseURL":"https://example.com/v1.0/","identifier":"v1.0","title":"v1.0"}]},"title":"My Website","weight":1},"pir":{"baseURL":"https://pir.example.com/","contentDir":"content/pir","languageCode":"art-x-pir","languageDirection":"rtl","languageName":"Pirrratish","params":{"version":"v2.0","versions":[{"baseURL":"https://pir.example.com/","identifier":"v2.0","isLatest":true,"title":"Latest"},{"baseURL":"https://pir.example.com/v1.0/","identifier":"v1.0","title":"v1.0"}]},"title":"Arrr, my Website","weight":2}}}
Hid'n th' Version'n Arrr
Opt'n If visitors navigate t' an archived version o' yer ship, they will see a version'n warning at th' top o' each plank.
Ye can dis'ble it be sett'n th' disableVersioningWarn'n opt'n t' true 'n yer hugo.toml.
hugo.
[params]disableVersioningWarn'n=true
params:disableVersioningWarn'n:true
{"params":{"disableVersioningWarning":true}}
Adjust'n th' Version'n Arrr
Method 1
Ye can adjust th' text o' th' version'n warning by overrid'n th' key Versioning-warning 'n yer i18n files.
Th' follow'n parameter be avail'ble t' be included 'n th' text:
pageVersion - th' element o' th' displayed page’s version from yer versions array
pageUrl - th' URL o' th' displayed plank
latestVersion - th' element o' th' version marked wit' isLatest from yer versions array
latestUrl - th' URL o' th' displayed plank mapped t' th' latest version
Method 2
Ye can override layouts/partials/versioning-war'n.html. This be called once a version conflict was recognized. So th' only th'n fer ye t' do be writ'n th' message.
Th' follow'n parameter be avail'ble 'n this partial:
Th' title will be used 'n meta informat'n o' yer HTML.
hugo.
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.
Social Media Images
When yer plank be shared on social media, ye can set a site-wide image t' display wit' th' link
hugo.
images=['images/hero.png']
images:- images/hero.png
{"images":["images/hero.png"]}
More Social Media Opt'ns
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.
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
hugo.
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
hugo.
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.
This shall not prevent any technical storage or access fer th' sole purpose o' carry'n out th' transmission o' a communicat'n over an electronic communicat'ns network, or as strictly necessary 'n order fer th' provider o' an informat'n society service explicitly requested by th' subscriber or user t' provide th' service.
Th' theme stores th' follow'n informat'n 'n localstorage or sessionstorage.
Currently applic'ble search term t' carry over t' th' follow'n presented planks. This will be used t' mark th' search term 'n th' page’s text.
By default this adds a printer ay'con 'n th' topbar but can be deactived. 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':
By default this adds a Marrrkdown ay'con 'n th' topbar but can be deactived. Click'n it switches t' th' Marrrkdown source includ'n th' title o' th' plank.
En'ble support t' show th' source code o' a plank if it was generated from a file. Add th' source output format t' yer home, section, an' plank 'n hugo.toml:
By default this adds a Source ay'con 'n th' topbar but can be deactived. Click'n it switches t' th' source code o' th' plank.
Th' Source output format differs from th' Marrrkdown format, as it prints th' source code as be includ'n th' front matter.
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.source 'n yer hugo.toml t' someth'n other than th' default o':
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.
hugo.
[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!.
hugo.
[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.