<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/">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>
<p>To create a home page, run the following command</p>
<divclass="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>
<p>To create a chapter page, run the following command</p>
<divclass="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></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>
<h3id="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>
<divclass="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="highlight"><pretabindex="0"class="chroma"><codeclass="language-shell"data-lang="shell"><spanclass="line"><spanclass="cl">hugo new <chapter>/<name>.md
<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>
<divclass="highlight"><pretabindex="0"class="chroma"><codeclass="language-shell"data-lang="shell"><spanclass="line"><spanclass="cl">hugo new --kind <kind><name>/_index.md
<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>
<tdstyle="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>
<tdstyle="text-align:left">article</td>
<tdstyle="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>
<p>Each hook file can be overridden of a specific <ahref="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>