Customizat'n

Serv'n yer plank from a subfolder

If yer ship be served from a subfolder, eg. https://example.com/mysite/, ye have t' set th' follow'n lines t' yer config.toml

baseURL = "https://example.com/mysite/"
canonifyURLs = true
relativeURLs = true

Without canonifyURLs=true URLs 'n sublemental planks (like sitemap.xml, rss.xml) will be generated falsly while yer HTML files will still work. See https://github.com/gohugoio/hugo/issues/5226.

Serv'n yer plank from th' filesystem

If ye want yer plank served from th' filesystem by us'n URLs start'n wit' file:// you’ll need th' follow'n configurat'n 'n yer config.toml:

relativeURLs = true

Th' theme will append an additional index.html t' all plank bundle links by default t' make th' plank 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 also generate th' links without this change by add'n this t' yer config.toml

[params]
  disableExplicitIndexURLs = true
Avast

If ye want t' use th' search feature from th' file system us'n 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.

If not already present, add th' follow'n lines 'n yer config.toml file.

[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.

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 config.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"]

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 .

Screenshot o' th' dedicated search page Screenshot o' th' dedicated search page

Avast

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 config.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 config.toml as seen below:

[outputs]
  home = ["HTML", "RSS", "PRINT", "SEARCH"]
  section = ["HTML", "RSS", "PRINT"]
  plank = ["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.

Avast

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 config.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 config.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"
...

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"

Th' home button be go'n t' look like this:

Default Home Button Default Home Button

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 0
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 doesn’t exist as th' menu be always hidden fer small screen sizes.

:root {
    --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.

  1. Write th' shortcode file layouts/shortcodes/myshortcode.html an' add th' follow'n line

    {{- .Store.Set "hasMyShortcode" true }}
  2. Add th' follow'n snippet t' yer config.toml

    [params.relearn.dependencies]
      [params.relearn.dependencies.myshortcode]
        name = "MyShortcode"
        locat'n = "footer"
  3. 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 yer config.toml.

    <script src="https://www.unpkg.com/jquery/dist/jquery.js"></script>

Character cas'n be relevant!

  • th' name sett'n 'n yer config.toml must match th' key (that needs t' be prefixed wit' a has) ye used fer th' store 'n yer layouts/shortcodes/myshortcode.html.
  • th' key on params.relearn.dependencies 'n yer config.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 config.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-formats
  • footer.html: th' footer o' th' plank. See output-formats
  • body.html: th' body o' th' plank. Th' body may contain o' one or many articles. See output-formats
  • article.html: th' output fer a single article, can contain elements around yer rrrambl'n. See output-formats
  • menu.html: left menu. Not meant t' be overwritten
  • search.html: search box. Not meant t' be overwritten
  • custom-header.html: custom headers 'n plank. Meant t' be overwritten when add'n CSS imports. Don’t forget t' include style 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' include javascript HTML tag directive 'n yer file.
  • favicon.html: th' favicon
  • 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’s headingPre 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’s headingPost sett'n into account.
  • logo.html: th' logo, on top left hand corner
  • meta.html: HTML meta tags, if ye want t' change default behavior
  • menu-pre.html: side-wide configurat'n t' prepend t' menu items. If ye override this, it be yer responsibility t' take th' page’s menuPre 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’s menuPost sett'n into account.
  • menu-footer.html: footer o' th' the left menu
  • toc.html: t'ble o' contents
  • rrrambl'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.