mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-12-18 03:43:31 +00:00
192 lines
14 KiB
HTML
192 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" dir="ltr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
|
<meta name="generator" content="Hugo 0.112.3">
|
|
<meta name="generator" content="Relearn 5.15.1+tip">
|
|
<meta name="description" content="Documentation for Hugo Relearn Theme">
|
|
<meta name="author" content="Sören Weber">
|
|
<title>Archetypes :: Hugo Relearn Theme</title>
|
|
<link href="https://McShelby.github.io/hugo-theme-relearn/cont/archetypes/index.html" rel="alternate" hreflang="x-default">
|
|
<link href="https://McShelby.github.io/hugo-theme-relearn/cont/archetypes/index.html" rel="alternate" hreflang="en">
|
|
<link href="https://McShelby.github.io/hugo-theme-relearn/pir/cont/archetypes/index.html" rel="alternate" hreflang="pir">
|
|
<link href="https://McShelby.github.io/hugo-theme-relearn/cont/archetypes/index.html" rel="canonical" type="text/html" title="Archetypes :: Hugo Relearn Theme">
|
|
<link href="../../cont/archetypes/index.xml" rel="alternate" type="application/rss+xml" title="Archetypes :: Hugo Relearn Theme">
|
|
<link href="../../images/logo.svg?1685225134" rel="icon" type="image/svg+xml">
|
|
<!-- https://github.com/filamentgroup/loadCSS/blob/master/README.md#how-to-use -->
|
|
<link href="../../css/fontawesome-all.min.css?1685225135" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="../../css/fontawesome-all.min.css?1685225135" rel="stylesheet"></noscript>
|
|
<link href="../../css/nucleus.css?1685225135" rel="stylesheet">
|
|
<link href="../../css/auto-complete.css?1685225135" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="../../css/auto-complete.css?1685225135" rel="stylesheet"></noscript>
|
|
<link href="../../css/perfect-scrollbar.min.css?1685225135" rel="stylesheet">
|
|
<link href="../../css/fonts.css?1685225135" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="../../css/fonts.css?1685225135" rel="stylesheet"></noscript>
|
|
<link href="../../css/theme.css?1685225135" rel="stylesheet">
|
|
<link href="../../css/theme-auto.css?1685225135" rel="stylesheet" id="variant-style">
|
|
<link href="../../css/variant.css?1685225135" rel="stylesheet">
|
|
<link href="../../css/print.css?1685225135" rel="stylesheet" media="print">
|
|
<link href="../../css/format-print.css?1685225135" rel="stylesheet">
|
|
<link href="../../css/ie.css?1685225135" rel="stylesheet">
|
|
<script src="../../js/url.js?1685225135"></script>
|
|
<script src="../../js/variant.js?1685225135"></script>
|
|
<script>
|
|
// hack to let hugo tell us how to get to the root when using relativeURLs, it needs to be called *url= for it to do its magic:
|
|
// https://github.com/gohugoio/hugo/blob/145b3fcce35fbac25c7033c91c1b7ae6d1179da8/transform/urlreplacers/absurlreplacer.go#L72
|
|
window.index_js_url="../../index.search.js";
|
|
var root_url="../../";
|
|
var baseUri=root_url.replace(/\/$/, '');
|
|
// translations
|
|
window.T_Copy_to_clipboard = 'Copy to clipboard';
|
|
window.T_Copied_to_clipboard = 'Copied to clipboard!';
|
|
window.T_Copy_link_to_clipboard = 'Copy link to clipboard';
|
|
window.T_Link_copied_to_clipboard = 'Copied link to clipboard!';
|
|
window.T_No_results_found = 'No results found for \u0022{0}\u0022';
|
|
window.T_N_results_found = '{1} results found for \u0022{0}\u0022';
|
|
// some further base stuff
|
|
var baseUriFull='https:\/\/McShelby.github.io\/hugo-theme-relearn/';
|
|
window.variants && variants.init( [ 'auto', 'relearn-bright', 'relearn-light', 'relearn-dark', 'learn', 'neon', 'blue', 'green', 'red' ] );
|
|
</script>
|
|
<style>
|
|
#body img.bg-white {
|
|
background-color: white;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="mobile-support print disableInlineCopyToClipboard" data-url="../../cont/archetypes/index.html">
|
|
<div id="body" class="default-animation">
|
|
<div id="sidebar-overlay"></div>
|
|
<div id="toc-overlay"></div>
|
|
<nav id="topbar" class="highlightable">
|
|
<div>
|
|
<div id="breadcrumbs">
|
|
<span id="sidebar-toggle-span">
|
|
<a href="#" id="sidebar-toggle" class="topbar-link" title='Menu (CTRL+ALT+n)'><i class="fas fa-bars fa-fw"></i></a>
|
|
</span>
|
|
<ol class="links" itemscope itemtype="http://schema.org/BreadcrumbList">
|
|
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement"><a itemprop="item" href="../../index.html"><span itemprop="name">Hugo Relearn Theme</span></a><meta itemprop="position" content="1"> > </li>
|
|
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement"><a itemprop="item" href="../../cont/index.html"><span itemprop="name">Content</span></a><meta itemprop="position" content="2"> > </li>
|
|
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement"><span itemprop="name">Archetypes</span><meta itemprop="position" content="3"></li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<main id="body-inner" class="highlightable default" tabindex="-1">
|
|
<div class="flex-block-wrapper">
|
|
<article class="default">
|
|
<header class="headline">
|
|
</header>
|
|
<h1 id="archetypes">Archetypes</h1>
|
|
|
|
<p>Using the command: <code>hugo new [relative new content path]</code>, you can start a content file with the date and title automatically set. While this is a welcome feature, active writers need more: <a href="https://gohugo.io/content/archetypes/" target="_blank">archetypes</a>. These are preconfigured skeleton pages with default frontmatter.</p>
|
|
<p>The Relearn theme defines some few archetypes of pages but you are free to define new ones to your liking. All can be used at any level of the documentation, the only difference being the layout of the content.</p>
|
|
<h2 id="predefined-archetypes">Predefined Archetypes</h2>
|
|
<h3 id="archetypes-home">Home</h3>
|
|
<p>A <strong>Home</strong> page is the starting page of your project. It’s best to have only one page of this kind in your project.</p>
|
|
<p>
|
|
|
|
<a href="#image-a3d825a8e687e9933e1549c9678c6bfe" class="lightbox-link">
|
|
<img src="../../cont/archetypes/pages-home.png?classes=shadow&width=60pc" alt="Home page" class="shadow" style="height: auto; width: 60pc;" loading="lazy">
|
|
</a>
|
|
<a href="javascript:history.back();" class="lightbox" id="image-a3d825a8e687e9933e1549c9678c6bfe">
|
|
<img src="../../cont/archetypes/pages-home.png?classes=shadow&width=60pc" alt="Home page" class="lightbox-image" loading="lazy">
|
|
</a></p>
|
|
<p>To create a home page, run the following command</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">hugo new --kind home _index.md
|
|
</span></span></code></pre></div><p>This leads to a file with the following content</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-markdown" data-lang="markdown"><span class="line"><span class="cl">+++
|
|
</span></span><span class="line"><span class="cl">archetype = "home"
|
|
</span></span><span class="line"><span class="cl">title = "{{ replace .Name "-" " " | title }}"
|
|
</span></span><span class="line"><span class="cl">+++
|
|
</span></span><span class="line"><span class="cl">
|
|
</span></span><span class="line"><span class="cl">Lorem Ipsum.
|
|
</span></span></code></pre></div><h3 id="archetypes-chapter">Chapter</h3>
|
|
<p>A <strong>Chapter</strong> displays a page meant to be used as introduction for a set of child pages. Commonly, it contains a simple title and a catch line to define content that can be found below it.</p>
|
|
<p>
|
|
|
|
<a href="#image-bb24849322dac74c70569598791eca13" class="lightbox-link">
|
|
<img src="../../cont/archetypes/pages-chapter.png?classes=shadow&width=60pc" alt="Chapter page" class="shadow" style="height: auto; width: 60pc;" loading="lazy">
|
|
</a>
|
|
<a href="javascript:history.back();" class="lightbox" id="image-bb24849322dac74c70569598791eca13">
|
|
<img src="../../cont/archetypes/pages-chapter.png?classes=shadow&width=60pc" alt="Chapter page" class="lightbox-image" loading="lazy">
|
|
</a></p>
|
|
<p>To create a chapter page, run the following command</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">hugo new --kind chapter <name>/_index.md
|
|
</span></span></code></pre></div><p>This leads to a file with the following content</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-markdown" data-lang="markdown"><span class="line"><span class="cl">+++
|
|
</span></span><span class="line"><span class="cl">archetype = "chapter"
|
|
</span></span><span class="line"><span class="cl">title = "{{ replace .Name "-" " " | title }}"
|
|
</span></span><span class="line"><span class="cl">weight = X
|
|
</span></span><span class="line"><span class="cl">+++
|
|
</span></span><span class="line"><span class="cl">
|
|
</span></span><span class="line"><span class="cl">Lorem Ipsum.
|
|
</span></span></code></pre></div><p>Replace the <code>X</code> with a number. Because this number will be used to generate the subtitle of the chapter page, set the number to a consecutive value starting at 1 for each new chapter level.</p>
|
|
<h3 id="archetypes-default">Default</h3>
|
|
<p>A <strong>Default</strong> page is any other content page. If you set an unknown archetype in your frontmatter, this archetype will be used to generate the page.</p>
|
|
<p>
|
|
|
|
<a href="#image-5b0a338e89be3cf649f8654f788ab546" class="lightbox-link">
|
|
<img src="../../cont/archetypes/pages-default.png?classes=shadow&width=60pc" alt="Default page" class="shadow" style="height: auto; width: 60pc;" loading="lazy">
|
|
</a>
|
|
<a href="javascript:history.back();" class="lightbox" id="image-5b0a338e89be3cf649f8654f788ab546">
|
|
<img src="../../cont/archetypes/pages-default.png?classes=shadow&width=60pc" alt="Default page" class="lightbox-image" loading="lazy">
|
|
</a></p>
|
|
<p>To create a default page, run either one of the following commands</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">hugo new <chapter>/<name>/_index.md
|
|
</span></span></code></pre></div><p>or</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">hugo new <chapter>/<name>.md
|
|
</span></span></code></pre></div><p>This leads to a file with the following content</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-markdown" data-lang="markdown"><span class="line"><span class="cl">+++
|
|
</span></span><span class="line"><span class="cl">title = "{{ replace .Name "-" " " | title }}"
|
|
</span></span><span class="line"><span class="cl">weight = X
|
|
</span></span><span class="line"><span class="cl">+++
|
|
</span></span><span class="line"><span class="cl">
|
|
</span></span><span class="line"><span class="cl">Lorem Ipsum.
|
|
</span></span></code></pre></div><p>Replace the <code>X</code> with a number or delete the whole <code>weight</code> parameter entirely.</p>
|
|
<h2 id="self-defined-archetypes">Self defined Archetypes</h2>
|
|
<p>If you are in need of further archetypes you can define your own or even redefine existing ones.</p>
|
|
<h3 id="template">Template</h3>
|
|
<p>Define a template file in your project at <code>archetypes/<kind>.md</code> and make sure it has at least the frontmatter parameter for that archetype like</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-markdown" data-lang="markdown"><span class="line"><span class="cl">+++
|
|
</span></span><span class="line"><span class="cl">archetype = "<span class="p"><</span><span class="nt">kind</span><span class="p">></span>"
|
|
</span></span><span class="line"><span class="cl">+++
|
|
</span></span></code></pre></div><p>Afterwards you can generate new content files of that kind with the following command</p>
|
|
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">hugo new --kind <kind> <name>/_index.md
|
|
</span></span></code></pre></div><h3 id="partials">Partials</h3>
|
|
<p>To define how your archetypes are rendered, define corresponding partial files in your projects directory <code>layouts/partials/archetypes/<kind></code>.</p>
|
|
<p>If you use an unknown archetype in your frontmatter, the <code>default</code> archetype will be used to generate the page.</p>
|
|
<p>Related to each archetype, several <em>hook</em> partial files in the form of <code><hook>.html</code> can be given inside each archetype directory. If a partial for a specific hook is missing, no output is generated for this hook.</p>
|
|
<p>The following hooks are used:</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th style="text-align:left">Name</th>
|
|
<th style="text-align:left">Notes</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td style="text-align:left">styleclass</td>
|
|
<td style="text-align:left">Defines a set of CSS classes to be added to the HTML’s <code><main></code> element. You can use these classes to define own CSS rules in your <code>custom-header.html</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:left">article</td>
|
|
<td style="text-align:left">Defines the HTML how to render your content</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Take a look at the existing archetypes of this theme to get an idea how to utilize it.</p>
|
|
<h4 id="output-formats">Output formats</h4>
|
|
<p>Each hook file can be overridden of a specific <a href="https://gohugo.io/templates/output-formats/" target="_blank">output format</a>. Eg. if you define a new output format <code>PLAINTEXT</code> in your <code>config.toml</code>, you can add a file <code>layouts/partials/archetypes/default.plaintext.html</code> to change the way how normal content is written for that output format.</p>
|
|
|
|
<footer class="footline">
|
|
|
|
</footer>
|
|
</article>
|
|
|
|
</div>
|
|
</main>
|
|
</div>
|
|
<script src="../../js/clipboard.min.js?1685225135" defer></script>
|
|
<script src="../../js/perfect-scrollbar.min.js?1685225135" defer></script>
|
|
<script src="../../js/theme.js?1685225135" defer></script>
|
|
</body>
|
|
</html>
|