Customizat'n
Usage scenarios
Th' theme be us'ble 'n different scenarios, requir'n th' follow'n mandatory sett'ns 'n yer hugo.toml
. All sett'ns not mentioned can be set t' yer lik'n.
Public Webserver from Root
baseURL = 'https://example.com/'
baseURL: https://example.com/
{
"baseURL": "https://example.com/"
}
Public Webserver from Subdirectory
baseURL = 'https://example.com/mysite/'
relativeURLs = false
baseURL: https://example.com/mysite/
relativeURLs: false
{
"baseURL": "https://example.com/mysite/",
"relativeURLs": false
}
Private Webserver (LAN)
Th' same sett'ns as wit' any o' th' public webserver usage scenarios or
baseURL = '/'
relativeURLs = true
baseURL: /
relativeURLs: true
{
"baseURL": "/",
"relativeURLs": true
}
File System
baseURL = '/'
relativeURLs = true
baseURL: /
relativeURLs: true
{
"baseURL": "/",
"relativeURLs": true
}
Us'n a baseURL
wit' a subdirectory an' relativeURLs=true
be mutally exclusive due t' th' fact, that Cap'n Hugo does not apply th' baseURL
correctly.
If ye need both, ye have t' generate yer ship twice but wit' different sett'ns into separate directories.
Sublemental planks (like sitemap.xml
, rss.xml
) an' generated social media links inside o' yer planks will always be generated wit' absolute URLs an' will not work if ye set relativeURLs=true
.
If ye be us'n uglyURLs=false
(Hugo’s default), th' theme will append an additional index.html
t' all plank links t' make yer ship be serv'ble from th' file system. If ye don’t care about th' file system an' only serve yer plank via a webserver ye can generate th' links without this:
[params]
disableExplicitIndexURLs = true
params:
disableExplicitIndexURLs: true
{
"params": {
"disableExplicitIndexURLs": true
}
}
Activate search
If not already present, add th' follow'n lines 'n yer hugo.toml
file.
[outputs]
home = ['html', 'rss', 'search']
outputs:
home:
- html
- rss
- search
{
"outputs": {
"home": [
"html",
"rss",
"search"
]
}
}
This will generate a search index file at th' root o' yer public folder ready t' be consumed by th' Lunr search library. Avast that th' search
outputformat was named json
'n previous releases but was implemented differently. Although json
still works, it be now deprecated.
If ye want t' use th' search feature from th' file system, migrat'n from an older installat'n o' th' theme, make sure t' change yer outputformat fer th' homepage from th' now deprecated json
t' search
as seen below.
Activate dedicated search plank
Ye can add a dedicated search plank fer yer plank by add'n th' searchpage
outputformat t' yer home plank by add'n th' follow'n lines 'n yer hugo.toml
file. This will cause Cap'n Hugo t' generate a new file http://example.com/mysite/search.html
.
[outputs]
home = ['html', 'rss', 'search', 'searchpage']
outputs:
home:
- html
- rss
- search
- searchpage
{
"outputs": {
"home": [
"html",
"rss",
"search",
"searchpage"
]
}
}
Ye can access this plank by either click'n on th' magnifier glass or by typ'n some search term an' press'n ENTER
inside o' th' menu’s search box .
T' have Cap'n Hugo create th' dedicated search plank successfully, ye must not generate th' URL http://example.com/mysite/search.html
from yer own rrrambl'n. This can happen if ye set uglyURLs=true
'n yer hugo.toml
an' defin'n a Marrrkdown file content/search.md
.
T' make sure, there be no duplicate rrrambl'n fer any given URL o' yer project, run hugo --printPathWarn'ns
.
Activate print support
Ye can activate print support t' add th' capability t' print whole chapters or even th' complete ship. Just add th' print
output format t' yer home, section an' plank 'n yer hugo.toml
as seen below:
[outputs]
home = ['html', 'rss', 'print', 'search']
plank = ['html', 'rss', 'print']
section = ['html', 'rss', 'print']
outputs:
home:
- html
- rss
- print
- search
plank:
- html
- rss
- print
section:
- html
- rss
- print
{
"outputs": {
"home": [
"html",
"rss",
"print",
"search"
],
"page": [
"html",
"rss",
"print"
],
"section": [
"html",
"rss",
"print"
]
}
}
This will add a little printer ay'con 'n th' top bar. It will switch th' plank t' print preview when clicked. Ye can then send this plank t' th' printer by us'n yer browser’s usual print functionality.
Th' result'n URL will not be configured ugly 'n terms o' Hugo’s URL handl'n even if you’ve set uglyURLs=true
'n yer hugo.toml
. This be due t' th' fact that fer one mime type only one suffix can be configured.
Nevertheless, if you’re unhappy wit' th' result'n URLs ye can manually redefine outputFormats.print
'n yer own hugo.toml
t' yer lik'n.
Home Button Configurat'n
If th' disableLandingPageButton
opt'n be set t' false
, a Home button will appear
on th' left menu. It be an alternative fer click'n on th' logo. T' edit th'
appearance, ye will have t' configure th' landingPageName
fer th' defined languages:
[languages]
[languages.en]
[languages.en.params]
landingPageName = "<i class='fas fa-home'></i> Home"
[languages.pir]
[languages.pir.params]
landingPageName = "<i class='fas fa-home'></i> Arrr! Homme"
languages:
en:
params:
landingPageName: <i class='fas fa-home'></i> Home
pir:
params:
landingPageName: <i class='fas fa-home'></i> Arrr! Homme
{
"languages": {
"en": {
"params": {
"landingPageName": "\u003ci class='fas fa-home'\u003e\u003c/i\u003e Home"
}
},
"pir": {
"params": {
"landingPageName": "\u003ci class='fas fa-home'\u003e\u003c/i\u003e Arrr! Homme"
}
}
}
}
If this opt'n be not configured fer a specific language, they will get their default values:
landingPageName = "<i class='fas fa-home'></i> Home"
landingPageName: <i class='fas fa-home'></i> Home
{
"landingPageName": "\u003ci class='fas fa-home'\u003e\u003c/i\u003e Home"
}
Th' home button be go'n t' look like this:
Social Media Meta Tags
Ye can add social media meta tags fer th' Open Graph protocol an' Twitter Cards t' yer ship. These be configured as mentioned 'n th' Cap'n Hugo docs.
Change th' Menu Width
Th' menu width adjusts automatically fer different screen sizes.
Name | Screen Width | Menu Width |
---|---|---|
S | < 48rem | 14.375rem |
M | 48rem - 60rem | 14.375rem |
L | >= 60rem | 18.75rem |
Th' values fer th' screen width breakpoints aren’t configur'ble.
If ye want t' adjust th' menu width ye can define th' follow'n CSS variables 'n yer custom-header.html
. Avast that --MENU-WIDTH-S
applies t' th' menu flyout width 'n mobile mode fer small screen sizes.
:root {
--MENU-WIDTH-S: 14.375rem;
--MENU-WIDTH-M: 14.375rem;
--MENU-WIDTH-L: 18.75rem;
}
Own Shorrrtcodes wit' JavaScript Dependencies
Certain shorrrtcodes make use o' additional JavaScript files. Th' theme only loads these dependencies if th' shortcode be used. T' do so correctly th' theme adds management code 'n various files.
Ye can ye use this mechanism 'n yer own shorrrtcodes. Say ye want t' add a shortcode myshortcode
that also requires th' jquery
JavaScript library.
-
Write th' shortcode file
layouts/shortcodes/myshortcode.html
an' add th' follow'n line{{- .Plank.Store.Set "hasMyShortcode" true }}
-
Add th' follow'n snippet t' yer
hugo.toml
hugo.[params] [params.relearn] [params.relearn.dependencies] [params.relearn.dependencies.myshortcode] locat'n = 'footer' name = 'MyShortcode'
params: relearn: dependencies: myshortcode: locat'n: footer name: MyShortcode
{ "params": { "relearn": { "dependencies": { "myshortcode": { "location": "footer", "name": "MyShortcode" } } } } }
-
Add th' dependency loader file
layouts/partials/dependencies/myshortcode.html
. Th' loader file will be appended t' yer header or footer, dependend on th'locat'n
sett'n 'n yerhugo.toml
.<script src="https://www.unpkg.com/jquery/dist/jquery.js"></script>
Character cas'n be relevant!
- th'
name
sett'n 'n yerhugo.toml
must match th' key (that needs t' be prefixed wit' ahas
) ye used fer th' store 'n yerlayouts/shortcodes/myshortcode.html
. - th' key on
params.relearn.dependencies
'n yerhugo.toml
must match th' base file name o' yer loader file.
See th' math
, mermaid
an' openapi
shorrrtcodes fer examples.
Output Formats
Certain parts o' th' theme can be changed fer support o' yer own output formats. Eg. if ye define a new output format PLAINTEXT
'n yer hugo.toml
, ye can add a file layouts/partials/header.plaintext.html
t' change th' way, th' plank header should look like fer that output format.
React t' Variant Switches 'n JavaScript
Once a color variant be fully boarded, either initially or by switch'n th' color variant manually wit' th' variant selector, th' custom event themeVariantLoaded
on th' document
will be dispatched. Ye can add an event listener an' react t' changes.
document.addEventListener( 'themeVariantLoaded', funct'n( e ){
console.log( e.detail.variant ); // `relearn-light`
});
Partials
Th' Relearrrn theme has been built t' be as configur'ble as poss'ble by defin'n multiple partials
In themes/hugo-theme-relearn/layouts/partials/
, ye will find all th' partials defined fer this theme. If ye need t' overwrite someth'n, don’t change th' code directly. Instead follow this plank. You’d create a new partial 'n th' layouts/partials
folder o' yer local project. This partial will have th' priority.
This theme defines th' follow'n partials :
header.html
: th' header o' th' plank. See output-formatsfooter.html
: th' footer o' th' plank. See output-formatsbody.html
: th' body o' th' plank. Th' body may contain o' one or many articles. See output-formatsarticle.html
: th' output fer a single article, can contain elements around yer rrrambl'n. See output-formatsmenu.html
: left menu. Not meant t' be overwrittensearch.html
: search box. Not meant t' be overwrittencustom-header.html
: custom headers 'n plank. Meant t' be overwritten when add'n CSS imports. Don’t forget t' includestyle
HTML tag directive 'n yer file.custom-footer.html
: custom footer 'n plank. Meant t' be overwritten when add'n JavaScript. Don’t forget t' includejavascript
HTML tag directive 'n yer file.favicon.html
: th' faviconhead'n.html
: side-wide configurat'n t' change th' planks title head'ns.heading-pre.html
: side-wide configurat'n t' prepend t' planks title head'ns. If ye override this, it be yer responsibility t' take th' page’sheadingPre
sett'n into account.heading-post.html
: side-wide configurat'n t' append t' planks title head'ns. If ye override this, it be yer responsibility t' take th' page’sheadingPost
sett'n into account.logo.html
: th' logo, on top left hand cornermeta.html
: HTML meta tags, if ye want t' change default behaviormenu-pre.html
: side-wide configurat'n t' prepend t' menu items. If ye override this, it be yer responsibility t' take th' page’smenuPre
sett'n into account.menu-post.html
: side-wide configurat'n t' append t' menu items. If ye override this, it be yer responsibility t' take th' page’smenuPost
sett'n into account.menu-footer.html
: footer o' th' the left menutoc.html
: t'ble o' contentsrrrambl'n.html
: th' rrrambl'n plank itself. This can be overridden if ye want t' display page’s meta data above or below th' rrrambl'n.content-header.html
: header above th' title, has a default implementat'n but ye can overwrite it if ye don’t like it.content-footer.html
: footer below th' rrrambl'n, has a default implementat'n but ye can overwrite it if ye don’t like it.