hugo-theme-relearn/cont/archetypes/index.print.html
2022-11-19 11:31:08 +00:00

176 lines
13 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.106.0">
<meta name="generator" content="Relearn 5.6.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="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?1668857461" 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?1668857462" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="../../css/fontawesome-all.min.css?1668857462" rel="stylesheet"></noscript>
<link href="../../css/featherlight.min.css?1668857462" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="../../css/featherlight.min.css?1668857462" rel="stylesheet"></noscript>
<link href="../../css/auto-complete.css?1668857462" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="../../css/auto-complete.css?1668857462" rel="stylesheet"></noscript>
<link href="../../css/perfect-scrollbar.min.css?1668857462" rel="stylesheet">
<link href="../../css/nucleus.css?1668857462" rel="stylesheet">
<link href="../../css/fonts.css?1668857462" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="../../css/fonts.css?1668857462" rel="stylesheet"></noscript>
<link href="../../css/theme.css?1668857462" rel="stylesheet">
<link href="../../css/theme-relearn-light.css?1668857462" rel="stylesheet" id="variant-style">
<link href="../../css/ie.css?1668857462" rel="stylesheet">
<link href="../../css/variant.css?1668857462" rel="stylesheet">
<link href="../../css/print.css?1668857462" rel="stylesheet" media="print">
<link href="../../css/format-print.css?1668857462" rel="stylesheet">
<script src="../../js/url.js?1668857462"></script>
<script src="../../js/variant.js?1668857462"></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( [ 'relearn-light', 'relearn-dark', 'learn', 'neon', 'blue', 'green', 'red' ] );
</script>
<script src="../../js/jquery.min.js?1668857462" defer></script>
</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" dir="ltr">
<div>
<div id="breadcrumbs">
<span id="sidebar-toggle-span">
<a href="#" id="sidebar-toggle" 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">
<div id="head-tags">
</div>
<article class="default">
<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/">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&rsquo;s best to have only one page of this kind in your project.</p>
<p>
<a href="../../cont/archetypes/pages-home.png?classes=shadow&amp;width=60pc" data-featherlight="image">
<img src="../../cont/archetypes/pages-home.png?classes=shadow&amp;width=60pc" alt="Home page" class="shadow" style="height: auto; width: 60pc;" 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 = &#34;home&#34;
</span></span><span class="line"><span class="cl">title = &#34;{{ replace .Name &#34;-&#34; &#34; &#34; | title }}&#34;
</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="../../cont/archetypes/pages-chapter.png?classes=shadow&amp;width=60pc" data-featherlight="image">
<img src="../../cont/archetypes/pages-chapter.png?classes=shadow&amp;width=60pc" alt="Chapter page" class="shadow" style="height: auto; width: 60pc;" 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 &lt;name&gt;/_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 = &#34;chapter&#34;
</span></span><span class="line"><span class="cl">title = &#34;{{ replace .Name &#34;-&#34; &#34; &#34; | title }}&#34;
</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="../../cont/archetypes/pages-default.png?classes=shadow&amp;width=60pc" data-featherlight="image">
<img src="../../cont/archetypes/pages-default.png?classes=shadow&amp;width=60pc" alt="Default page" class="shadow" style="height: auto; width: 60pc;" 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 &lt;chapter&gt;/&lt;name&gt;/_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 &lt;chapter&gt;/&lt;name&gt;.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 = &#34;{{ replace .Name &#34;-&#34; &#34; &#34; | title }}&#34;
</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/&lt;kind&gt;.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 = &#34;<span class="p">&lt;</span><span class="nt">kind</span><span class="p">&gt;</span>&#34;
</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 &lt;kind&gt; &lt;name&gt;/_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/&lt;kind&gt;</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>&lt;hook&gt;.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&rsquo;s <code>&lt;main&gt;</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/">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?1668857462" defer></script>
<script src="../../js/perfect-scrollbar.min.js?1668857462" defer></script>
<script src="../../js/featherlight.min.js?1668857462" defer></script>
<script src="../../js/theme.js?1668857462" defer></script>
</body>
</html>