<linkhref="https://McShelby.github.io/hugo-theme-relearn/basics/customization/index.html"rel="canonical"type="text/html"title="Customization :: Hugo Relearn Theme">
<p>If your site is served from a subfolder, eg. <code>https://example.com/mysite/</code>, you have to set the following lines to your <code>hugo.toml</code></p>
</span></span><spanclass="line"><spanclass="cl"><spanclass="nx">relativeURLs</span><spanclass="p">=</span><spanclass="kc">true</span></span></span></code></pre></div><p>Without <code>canonifyURLs=true</code> URLs in sublemental pages (like <code>sitemap.xml</code>, <code>rss.xml</code>) will be generated falsly while your HTML files will still work. See <ahref="https://github.com/gohugoio/hugo/issues/5226"target="_blank">https://github.com/gohugoio/hugo/issues/5226</a>.</p>
<h2id="serving-your-page-from-the-filesystem">Serving your page from the filesystem</h2>
<p>If you want your page served from the filesystem by using URLs starting with <code>file://</code> you’ll need the following configuration in your <code>hugo.toml</code>:</p>
<divclass="wrap-code highlight"><pretabindex="0"class="chroma"><codeclass="language-toml"data-lang="toml"><spanclass="line"><spanclass="cl"><spanclass="nx">relativeURLs</span><spanclass="p">=</span><spanclass="kc">true</span></span></span></code></pre></div><p>The theme will append an additional <code>index.html</code> to all page bundle links by default to make the page be servable from the file system. If you don’t care about the file system and only serve your page via a webserver you can also generate the links without this change by adding this to your <code>hugo.toml</code></p>
<p>If you want to use the search feature from the file system using an older installation of the theme make sure to change your outputformat for the homepage from the now deprecated <code>JSON</code> to <code>SEARCH</code><ahref="#activate-search">as seen below</a>.</p>
</span></span><spanclass="line"><spanclass="cl"><spanclass="nx">home</span><spanclass="p">=</span><spanclass="p">[</span><spanclass="s2">"HTML"</span><spanclass="p">,</span><spanclass="s2">"RSS"</span><spanclass="p">,</span><spanclass="s2">"SEARCH"</span><spanclass="p">]</span></span></span></code></pre></div><p>This will generate a search index file at the root of your public folder ready to be consumed by the Lunr search library. Note that the <code>SEARCH</code> outputformat was named <code>JSON</code> in previous releases but was implemented differently. Although <code>JSON</code> still works, it is now deprecated.</p>
<p>You can add a dedicated search page for your page by adding the <code>SEARCHPAGE</code> outputformat to your home page by adding the following lines in your <code>hugo.toml</code> file. This will cause Hugo to generate a new file <code>http://example.com/mysite/search.html</code>.</p>
</span></span><spanclass="line"><spanclass="cl"><spanclass="nx">home</span><spanclass="p">=</span><spanclass="p">[</span><spanclass="s2">"HTML"</span><spanclass="p">,</span><spanclass="s2">"RSS"</span><spanclass="p">,</span><spanclass="s2">"SEARCH"</span><spanclass="p">,</span><spanclass="s2">"SEARCHPAGE"</span><spanclass="p">]</span></span></span></code></pre></div><p>You can access this page by either clicking on the magnifier glass or by typing some search term and pressing <code>ENTER</code> inside of the menu’s search box .</p>
<p><ahref="#R-image-f820956fff775a52d4a111f8dacb7bd2"class="lightbox-link"><imgsrc="../../basics/customization/search_page.png?&width=60pc"alt="Screenshot of the dedicated search page"class="figure-image bg-white border lightbox noshadow"style="height: auto; width: 60pc;"loading="lazy"></a>
<ahref="javascript:history.back();"class="lightbox-back"id="R-image-f820956fff775a52d4a111f8dacb7bd2"><imgsrc="../../basics/customization/search_page.png?&width=60pc"alt="Screenshot of the dedicated search page"class="lightbox-image bg-white border lightbox noshadow"loading="lazy"></a></p>
<p>To have Hugo create the dedicated search page successfully, you must not generate the URL <code>http://example.com/mysite/search.html</code> from your own content. This can happen if you set <code>uglyURLs=true</code> in your <code>hugo.toml</code> and defining a Markdown file <code>content/search.md</code>.</p>
<p>You can activate print support to add the capability to print whole chapters or even the complete site. Just add the <code>PRINT</code> output format to your home, section and page in your <code>hugo.toml</code> as seen below:</p>
</span></span><spanclass="line"><spanclass="cl"><spanclass="nx">page</span><spanclass="p">=</span><spanclass="p">[</span><spanclass="s2">"HTML"</span><spanclass="p">,</span><spanclass="s2">"RSS"</span><spanclass="p">,</span><spanclass="s2">"PRINT"</span><spanclass="p">]</span></span></span></code></pre></div><p>This will add a little printer icon in the top bar. It will switch the page to print preview when clicked. You can then send this page to the printer by using your browser’s usual print functionality.</p>
<p>The resulting URL will not be <ahref="https://gohugo.io/templates/output-formats/#configure-output-formats"target="_blank">configured ugly</a> in terms of <ahref="https://gohugo.io/content-management/urls/#ugly-urls"target="_blank">Hugo’s URL handling</a> even if you’ve set <code>uglyURLs=true</code> in your <code>hugo.toml</code>. This is due to the fact that for one mime type only one suffix can be configured.</p>
<p>Nevertheless, if you’re unhappy with the resulting URLs you can manually redefine <code>outputFormats.PRINT</code> in your own <code>hugo.toml</code> to your liking.</p>
</span></span><spanclass="line"><spanclass="cl"><spanclass="p">...</span></span></span></code></pre></div><p>If this option is not configured for a specific language, they will get their default values:</p>
<divclass="wrap-code highlight"><pretabindex="0"class="chroma"><codeclass="language-toml"data-lang="toml"><spanclass="line"><spanclass="cl"><spanclass="nx">landingPageName</span><spanclass="p">=</span><spanclass="s2">"<i class='fas fa-home'></i> Home"</span></span></span></code></pre></div><p>The home button is going to look like this:</p>
<h2id="social-media-meta-tags">Social Media Meta Tags</h2>
<p>You can add social media meta tags for the <ahref="https://gohugo.io/templates/internal/#open-graph"target="_blank">Open Graph</a> protocol and <ahref="https://gohugo.io/templates/internal/#twitter-cards"target="_blank">Twitter Cards</a> to your site. These are configured as mentioned in the Hugo docs.</p>
<h2id="change-the-menu-width">Change the Menu Width</h2>
<p>The menu width adjusts automatically for different screen sizes.</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Screen Width</th>
<th>Menu Width</th>
</tr>
</thead>
<tbody>
<tr>
<td>S</td>
<td>< 48rem</td>
<td>0</td>
</tr>
<tr>
<td>M</td>
<td>48rem - 60rem</td>
<td>14.375rem</td>
</tr>
<tr>
<td>L</td>
<td>>= 60rem</td>
<td>18.75rem</td>
</tr>
</tbody>
</table>
<p>The values for the screen width breakpoints aren’t configurable.</p>
<p>If you want to adjust the menu width you can define the following CSS variables in your <code>custom-header.html</code>. Note that <code>--MENU-WIDTH-S</code> doesn’t exist as the menu is always hidden for small screen sizes.</p>
</span></span><spanclass="line"><spanclass="cl"><spanclass="p">}</span></span></span></code></pre></div><h2id="own-shortcodes-with-javascript-dependencies">Own Shortcodes with JavaScript Dependencies</h2>
<p>Certain shortcodes make use of additional JavaScript files. The theme only loads these dependencies if the shortcode is used. To do so correctly the theme adds management code in various files.</p>
<p>You can you use this mechanism in your own shortcodes. Say you want to add a shortcode <code>myshortcode</code> that also requires the <code>jquery</code> JavaScript library.</p>
<p>Add the dependency loader file <code>layouts/partials/dependencies/myshortcode.html</code>. The loader file will be appended to your header or footer, dependend on the <code>location</code> setting in your <code>hugo.toml</code>.</p>
<li>the <code>name</code> setting in your <code>hugo.toml</code> must match the key (that needs to be prefixed with a <code>has</code>) you used for the store in your <code>layouts/shortcodes/myshortcode.html</code>.</li>
<li>the key on <code>params.relearn.dependencies</code> in your <code>hugo.toml</code> must match the base file name of your loader file.</li>
<p>Certain parts of the theme can be changed for support of your own <ahref="https://gohugo.io/templates/output-formats/"target="_blank">output formats</a>. Eg. if you define a new output format <code>PLAINTEXT</code> in your <code>hugo.toml</code>, you can add a file <code>layouts/partials/header.plaintext.html</code> to change the way, the page header should look like for that output format.</p>
<h2id="react-to-variant-switches-in-javascript">React to Variant Switches in JavaScript</h2>
<p>Once a color variant is fully loaded, either initially or by switching the color variant manually with the variant selector, the custom event <code>themeVariantLoaded</code> on the <code>document</code> will be dispatched. You can add an event listener and react to changes.</p>
<p>The Relearn theme has been built to be as configurable as possible by defining multiple <ahref="https://gohugo.io/templates/partials/"target="_blank">partials</a></p>
<p>In <code>themes/hugo-theme-relearn/layouts/partials/</code>, you will find all the partials defined for this theme. If you need to overwrite something, don’t change the code directly. Instead <ahref="https://gohugo.io/themes/customizing/"target="_blank">follow this page</a>. You’d create a new partial in the <code>layouts/partials</code> folder of your local project. This partial will have the priority.</p>
<p>This theme defines the following partials :</p>
<ul>
<li><code>header.html</code>: the header of the page. See <ahref="#output-formats">output-formats</a></li>
<li><code>footer.html</code>: the footer of the page. See <ahref="#output-formats">output-formats</a></li>
<li><code>body.html</code>: the body of the page. The body may contain of one or many articles. See <ahref="#output-formats">output-formats</a></li>
<li><code>article.html</code>: the output for a single article, can contain elements around your content. See <ahref="#output-formats">output-formats</a></li>
<li><code>menu.html</code>: left menu. <em>Not meant to be overwritten</em></li>
<li><code>search.html</code>: search box. <em>Not meant to be overwritten</em></li>
<li><code>custom-header.html</code>: custom headers in page. Meant to be overwritten when adding CSS imports. Don’t forget to include <code>style</code> HTML tag directive in your file.</li>
<li><code>custom-footer.html</code>: custom footer in page. Meant to be overwritten when adding JavaScript. Don’t forget to include <code>javascript</code> HTML tag directive in your file.</li>
<li><code>heading-pre.html</code>: side-wide configuration to prepend to pages title headings. If you override this, it is your responsibility to take the page’s <code>headingPre</code> setting into account.</li>
<li><code>heading-post.html</code>: side-wide configuration to append to pages title headings. If you override this, it is your responsibility to take the page’s <code>headingPost</code> setting into account.</li>
<li><code>logo.html</code>: the logo, on top left hand corner</li>
<li><code>meta.html</code>: HTML meta tags, if you want to change default behavior</li>
<li><code>menu-pre.html</code>: side-wide configuration to prepend to menu items. If you override this, it is your responsibility to take the page’s <code>menuPre</code> setting into account.</li>
<li><code>menu-post.html</code>: side-wide configuration to append to menu items. If you override this, it is your responsibility to take the page’s <code>menuPost</code> setting into account.</li>
<li><code>menu-footer.html</code>: footer of the the left menu</li>
<li><code>toc.html</code>: table of contents</li>
<li><code>content.html</code>: the content page itself. This can be overridden if you want to display page’s meta data above or below the content.</li>
<li><code>content-header.html</code>: header above the title, has a default implementation but you can overwrite it if you don’t like it.</li>
<li><code>content-footer.html</code>: footer below the content, has a default implementation but you can overwrite it if you don’t like it.</li>