feat: Add note on adding notes ;)
This commit is contained in:
61
content/notes/adding-post-type-hugo.md
Normal file
61
content/notes/adding-post-type-hugo.md
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: "Adding another post type to Hugo"
|
||||
date: 2025-12-14T7:30:00+02:00
|
||||
draft: false
|
||||
subtitle: "How I added notes as content type to hugo in addition to the standard posts and pages."
|
||||
---
|
||||
|
||||
|
||||
Notes are short posts that focus on a small bit of information. Other than my blogposts they do not try to give a
|
||||
complete picture or a full explanation. They are more of a brain-dump of mine with a low bar of typing them out.
|
||||
|
||||
So how did I add them?
|
||||
|
||||
1. **Create a notes folder:** The folder in `content/notes` will hold the notes
|
||||
2. **Add rendering template:** Hugo needs to know what to do here, so add a rendering template in
|
||||
`layouts/notes/list.html`. A sample is provided below.
|
||||
3. Add `content/notes/_index.md` with a short explanation of the
|
||||
|
||||
### Styling template
|
||||
|
||||
```html
|
||||
{{ define "main" }}
|
||||
<h1">Notes</h1>
|
||||
|
||||
<div>
|
||||
{{ .Content }}
|
||||
</div>
|
||||
|
||||
|
||||
<ul>
|
||||
{{ range .Pages.ByDate.Reverse }}
|
||||
<li
|
||||
">
|
||||
<h2>
|
||||
<a href="{{ .Permalink }} "> {{ .Title }} </a>
|
||||
</h2>
|
||||
<small">{{ .Date.Format "2006-01-02" }}</small>
|
||||
{{ if .Params.subtitle }}
|
||||
<p>{{ .Params.subtitle }}</p>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
|
||||
```
|
||||
|
||||
As you can see, I added an optional subtitel. They make it much easier to find a note that is interesting, but should
|
||||
not be necessary to lower the bar for the author. Subtitles can be specified like this
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: "Adding another post type to Hugo"
|
||||
date: 2025-12-14T7:30:00+02:00
|
||||
draft: false
|
||||
subtitle: "How I added notes as content type to hugo in addition to the standard posts and pages."
|
||||
---
|
||||
|
||||
|
||||
Notes are short posts
|
||||
```
|
||||
Reference in New Issue
Block a user