<linkhref="https://McShelby.github.io/hugo-theme-relearn/cont/archetypes/index.html"rel="canonical"type="text/html"title="Archetypes :: Hugo Relearn Theme">
<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: <ahref="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>
<divclass="wrap-code highlight"><pretabindex="0"class="chroma"><codeclass="language-shell"data-lang="shell"><spanclass="line"><spanclass="cl">hugo new --kind home _index.md</span></span></code></pre></div><p>This leads to a file with the following content</p>
<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>
<divclass="wrap-code highlight"><pretabindex="0"class="chroma"><codeclass="language-shell"data-lang="shell"><spanclass="line"><spanclass="cl">hugo new --kind chapter <name>/_index.md</span></span></code></pre></div><p>This leads to a file with the following content</p>
</span></span><spanclass="line"><spanclass="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>
<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>
<divclass="wrap-code highlight"><pretabindex="0"class="chroma"><codeclass="language-shell"data-lang="shell"><spanclass="line"><spanclass="cl">hugo new <chapter>/<name>/_index.md</span></span></code></pre></div><p>or</p>
<divclass="wrap-code highlight"><pretabindex="0"class="chroma"><codeclass="language-shell"data-lang="shell"><spanclass="line"><spanclass="cl">hugo new <chapter>/<name>.md</span></span></code></pre></div><p>This leads to a file with the following content</p>
</span></span><spanclass="line"><spanclass="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>
<p>If you are in need of further archetypes you can define your own or even redefine existing ones.</p>
<h3id="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>
</span></span><spanclass="line"><spanclass="cl">+++</span></span></code></pre></div><p>Afterwards you can generate new content files of that kind with the following command</p>
<divclass="wrap-code highlight"><pretabindex="0"class="chroma"><codeclass="language-shell"data-lang="shell"><spanclass="line"><spanclass="cl">hugo new --kind <kind><name>/_index.md</span></span></code></pre></div><h3id="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>
<td>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>
<p>Each hook file can be overridden of a specific <ahref="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>