hugo-theme-relearn/cont/archetypes/index.print.html

267 lines
20 KiB
HTML
Raw Normal View History

<!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.125.3">
<meta name="generator" content="Relearn 5.27.0+tip">
<meta name="description" content="Using the command: hugo new [relative new content path], you can start a content file with the date and title automatically set.">
<meta name="author" content="Sören Weber">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://mcshelby.github.io/hugo-theme-relearn/images/hero.png">
<meta name="twitter:title" content="Archetypes :: Hugo Relearn Theme">
<meta name="twitter:description" content="Using the command: hugo new [relative new content path], you can start a content file with the date and title automatically set.">
<meta property="og:url" content="https://mcshelby.github.io/hugo-theme-relearn/cont/archetypes/index.html">
<meta property="og:site_name" content="Hugo Relearn Theme">
<meta property="og:title" content="Archetypes :: Hugo Relearn Theme">
<meta property="og:description" content="Using the command: hugo new [relative new content path], you can start a content file with the date and title automatically set.">
<meta property="og:locale" content="en">
<meta property="og:type" content="website">
<meta property="og:image" content="https://mcshelby.github.io/hugo-theme-relearn/images/hero.png">
<meta itemprop="name" content="Archetypes :: Hugo Relearn Theme">
<meta itemprop="description" content="Using the command: hugo new [relative new content path], you can start a content file with the date and title automatically set.">
<meta itemprop="wordCount" content="577">
<meta itemprop="image" content="https://mcshelby.github.io/hugo-theme-relearn/images/hero.png">
<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="art-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="/hugo-theme-relearn/cont/archetypes/index.xml" rel="alternate" type="application/rss+xml" title="Archetypes :: Hugo Relearn Theme">
<link href="/hugo-theme-relearn/images/logo.svg?1713993130" rel="icon" type="image/svg+xml">
<link href="/hugo-theme-relearn/css/fontawesome-all.min.css?1713993131" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="/hugo-theme-relearn/css/fontawesome-all.min.css?1713993131" rel="stylesheet"></noscript>
<link href="/hugo-theme-relearn/css/nucleus.css?1713993131" rel="stylesheet">
<link href="/hugo-theme-relearn/css/auto-complete.css?1713993131" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="/hugo-theme-relearn/css/auto-complete.css?1713993131" rel="stylesheet"></noscript>
<link href="/hugo-theme-relearn/css/perfect-scrollbar.min.css?1713993131" rel="stylesheet">
<link href="/hugo-theme-relearn/css/fonts.css?1713993131" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="/hugo-theme-relearn/css/fonts.css?1713993131" rel="stylesheet"></noscript>
<link href="/hugo-theme-relearn/css/theme.css?1713993131" rel="stylesheet">
<link href="/hugo-theme-relearn/css/theme-relearn-auto.css?1713993131" rel="stylesheet" id="R-variant-style">
<link href="/hugo-theme-relearn/css/chroma-relearn-auto.css?1713993131" rel="stylesheet" id="R-variant-chroma-style">
<link href="/hugo-theme-relearn/css/variant.css?1713993131" rel="stylesheet">
<link href="/hugo-theme-relearn/css/print.css?1713993131" rel="stylesheet" media="print">
<link href="/hugo-theme-relearn/css/format-print.css?1713993131" rel="stylesheet">
<script src="/hugo-theme-relearn/js/variant.js?1713993131"></script>
<script>
window.relearn = window.relearn || {};
window.relearn.relBasePath='..\/..';
window.relearn.relBaseUri='..\/..\/..';
window.relearn.absBaseUri='https:\/\/mcshelby.github.io\/hugo-theme-relearn';
window.index_js_url="/hugo-theme-relearn/index.search.js";
// variant stuff
window.variants && variants.init( [ 'relearn-auto', 'relearn-light', 'relearn-dark', 'relearn-bright', 'zen-auto', 'zen-light', 'zen-dark', 'retro-auto', 'neon', 'learn', 'blue', 'green', 'red' ] );
// 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_Reset_view = `Reset view`;
window.T_View_reset = `View reset!`;
window.T_No_results_found = `No results found for "{0}"`;
window.T_N_results_found = `{1} results found for "{0}"`;
</script>
<style>
#R-body img.bg-white {
background-color: white;
}
</style>
</head>
<body class="mobile-support print disableInlineCopyToClipboard" data-url="/hugo-theme-relearn/cont/archetypes/index.html">
<div id="R-body" class="default-animation">
<div id="R-body-overlay"></div>
<nav id="R-topbar">
<div class="topbar-wrapper">
<div class="topbar-sidebar-divider"></div>
<div class="topbar-area topbar-area-start" data-area="start">
<div class="topbar-button topbar-button-sidebar" data-content-empty="disable" data-width-s="show" data-width-m="hide" data-width-l="hide"><button class="topbar-control" onclick="toggleNav()" type="button" title="Menu (CTRL&#43;ALT&#43;n)"><i class="fa-fw fas fa-bars"></i></button>
</div>
</div>
<ol class="topbar-breadcrumbs breadcrumbs highlightable" itemscope itemtype="http://schema.org/BreadcrumbList"><li
itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement"><a itemprop="item" href="/hugo-theme-relearn/cont/index.html"><span itemprop="name">Content</span></a><meta itemprop="position" content="1">&nbsp;>&nbsp;</li><li
itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement"><span itemprop="name">Archetypes</span><meta itemprop="position" content="2"></li>
</ol>
<div class="topbar-area topbar-area-end" data-area="end">
<div class="topbar-button topbar-button-prev" data-content-empty="disable" data-width-s="show" data-width-m="show" data-width-l="show"><a class="topbar-control" href="/hugo-theme-relearn/cont/frontmatter/index.html" title="Frontmatter (🡐)"><i class="fa-fw fas fa-chevron-left"></i></a>
</div>
<div class="topbar-button topbar-button-next" data-content-empty="disable" data-width-s="show" data-width-m="show" data-width-l="show"><a class="topbar-control" href="/hugo-theme-relearn/cont/markdown/index.html" title="Markdown Syntax (🡒)"><i class="fa-fw fas fa-chevron-right"></i></a>
</div>
</div>
</div>
</nav>
<div id="R-main-overlay"></div>
<main id="R-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/" rel="external" target="_self">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="#R-image-ffa68c94e79ced9ca2e1eab72990aa35" class="lightbox-link"><img alt="Home page" class="bg-white border lazy lightbox noshadow figure-image" loading="lazy" src="/hugo-theme-relearn/cont/archetypes/pages-home.png?width=60pc" style=" height: auto; width: 60pc;"></a>
<a href="javascript:history.back();" class="lightbox-back" id="R-image-ffa68c94e79ced9ca2e1eab72990aa35"><img alt="Home page" class="bg-white border lazy lightbox noshadow lightbox-image" loading="lazy" src="/hugo-theme-relearn/cont/archetypes/pages-home.png?width=60pc"></a></p>
<p>To create a home page, run the following command</p>
<div class="highlight wrap-code"><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="tab-panel" data-tab-group="dec78f2306896ed1fd6aa6095b133e6b">
<div class="tab-nav">
<div class="tab-nav-title">&#8203;</div>
<button
data-tab-item="_indexmd"
class="tab-nav-button tab-panel-style cstyle initial active" tabindex="-1"
onclick="switchTab('dec78f2306896ed1fd6aa6095b133e6b','_indexmd')"
>
<span class="tab-nav-text">_index.md</span>
</button>
</div>
<div class="tab-content-container">
<div
data-tab-item="_indexmd"
class="tab-content tab-panel-style cstyle initial active">
<div class="tab-content-text">
<div class="highlight wrap-code"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="err">+++</span>
</span></span><span class="line"><span class="cl"><span class="nx">archetype</span> <span class="p">=</span> <span class="s2">&#34;home&#34;</span>
</span></span><span class="line"><span class="cl"><span class="nx">title</span> <span class="p">=</span> <span class="s2">&#34;{{ replace .Name &#34;</span><span class="nx">-</span><span class="s2">&#34; &#34;</span> <span class="s2">&#34; | title }}&#34;</span>
</span></span><span class="line"><span class="cl"><span class="err">+++</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">Lorem</span> <span class="nx">Ipsum</span><span class="p">.</span></span></span></code></pre></div></div>
</div>
</div>
</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="#R-image-c95cbcfd2349df12c86686ba83365b4a" class="lightbox-link"><img alt="Chapter page" class="bg-white border lazy lightbox noshadow figure-image" loading="lazy" src="/hugo-theme-relearn/cont/archetypes/pages-chapter.png?width=60pc" style=" height: auto; width: 60pc;"></a>
<a href="javascript:history.back();" class="lightbox-back" id="R-image-c95cbcfd2349df12c86686ba83365b4a"><img alt="Chapter page" class="bg-white border lazy lightbox noshadow lightbox-image" loading="lazy" src="/hugo-theme-relearn/cont/archetypes/pages-chapter.png?width=60pc"></a></p>
<p>To create a chapter page, run the following command</p>
<div class="highlight wrap-code"><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="tab-panel" data-tab-group="04e48d6fb0ca4df4b2fb53a885535ec0">
<div class="tab-nav">
<div class="tab-nav-title">&#8203;</div>
<button
data-tab-item="_indexmd"
class="tab-nav-button tab-panel-style cstyle initial active" tabindex="-1"
onclick="switchTab('04e48d6fb0ca4df4b2fb53a885535ec0','_indexmd')"
>
<span class="tab-nav-text">_index.md</span>
</button>
</div>
<div class="tab-content-container">
<div
data-tab-item="_indexmd"
class="tab-content tab-panel-style cstyle initial active">
<div class="tab-content-text">
<div class="highlight wrap-code"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="err">+++</span>
</span></span><span class="line"><span class="cl"><span class="nx">archetype</span> <span class="p">=</span> <span class="s2">&#34;chapter&#34;</span>
</span></span><span class="line"><span class="cl"><span class="nx">title</span> <span class="p">=</span> <span class="s2">&#34;{{ replace .Name &#34;</span><span class="nx">-</span><span class="s2">&#34; &#34;</span> <span class="s2">&#34; | title }}&#34;</span>
</span></span><span class="line"><span class="cl"><span class="nx">weight</span> <span class="p">=</span> <span class="mi">1</span>
</span></span><span class="line"><span class="cl"><span class="err">+++</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">Lorem</span> <span class="nx">Ipsum</span><span class="p">.</span></span></span></code></pre></div></div>
</div>
</div>
</div><p>The <code>weight</code> 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="#R-image-d6df41e9865b0249b3796ec6ee8d4e32" class="lightbox-link"><img alt="Default page" class="bg-white border lazy lightbox noshadow figure-image" loading="lazy" src="/hugo-theme-relearn/cont/archetypes/pages-default.png?width=60pc" style=" height: auto; width: 60pc;"></a>
<a href="javascript:history.back();" class="lightbox-back" id="R-image-d6df41e9865b0249b3796ec6ee8d4e32"><img alt="Default page" class="bg-white border lazy lightbox noshadow lightbox-image" loading="lazy" src="/hugo-theme-relearn/cont/archetypes/pages-default.png?width=60pc"></a></p>
<p>To create a default page, run either one of the following commands</p>
<div class="highlight wrap-code"><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 wrap-code"><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="tab-panel" data-tab-group="f615c9fc774883bb32dac0c2a0a672a5">
<div class="tab-nav">
<div class="tab-nav-title">&#8203;</div>
<button
data-tab-item="md"
class="tab-nav-button tab-panel-style cstyle initial active" tabindex="-1"
onclick="switchTab('f615c9fc774883bb32dac0c2a0a672a5','md')"
>
<span class="tab-nav-text">*.md</span>
</button>
</div>
<div class="tab-content-container">
<div
data-tab-item="md"
class="tab-content tab-panel-style cstyle initial active">
<div class="tab-content-text">
<div class="highlight wrap-code"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="err">+++</span>
</span></span><span class="line"><span class="cl"><span class="nx">title</span> <span class="p">=</span> <span class="s2">&#34;{{ replace .Name &#34;</span><span class="nx">-</span><span class="s2">&#34; &#34;</span> <span class="s2">&#34; | title }}&#34;</span>
</span></span><span class="line"><span class="cl"><span class="err">+++</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">Lorem</span> <span class="nx">Ipsum</span><span class="p">.</span></span></span></code></pre></div></div>
</div>
</div>
</div><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="tab-panel" data-tab-group="9b96039928618bfcd385cbff692e8a46">
<div class="tab-nav">
<div class="tab-nav-title">&#8203;</div>
<button
data-tab-item="ltkindgtmd"
class="tab-nav-button tab-panel-style cstyle initial active" tabindex="-1"
onclick="switchTab('9b96039928618bfcd385cbff692e8a46','ltkindgtmd')"
>
<span class="tab-nav-text">&lt;kind&gt;.md</span>
</button>
</div>
<div class="tab-content-container">
<div
data-tab-item="ltkindgtmd"
class="tab-content tab-panel-style cstyle initial active">
<div class="tab-content-text">
<div class="highlight wrap-code"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="err">+++</span>
</span></span><span class="line"><span class="cl"><span class="nx">archetype</span> <span class="p">=</span> <span class="s2">&#34;&lt;kind&gt;&#34;</span>
</span></span><span class="line"><span class="cl"><span class="err">+++</span></span></span></code></pre></div></div>
</div>
</div>
</div><p>Afterwards you can generate new content files of that kind with the following command</p>
<div class="highlight wrap-code"><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>Name</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>styleclass</td>
<td>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>article</td>
<td>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/" rel="external" target="_self">output format</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/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="/hugo-theme-relearn/js/clipboard.min.js?1713993131" defer></script>
<script src="/hugo-theme-relearn/js/perfect-scrollbar.min.js?1713993131" defer></script>
<script src="/hugo-theme-relearn/js/theme.js?1713993131" defer></script>
</body>
</html>