Where to keep unstructured text?

Let’s say I have a page like this and I have about.md with a corresponding about.html layout file.

Normally, I would hardcode the text for this page inside the about.html because there’s no clear structure like in a blog post and there are different CSS styles being used for the different parts. The problem is it’s a little hard for non-technical people to change the text this way.

What’s the correct way to manage this kind of content in Hugo?

For pages that need some custom look and content I create a custom template as you have done and then either put the content in the frontmatter or use shortcodes to wrap sections of the content in the body in html tags with needed classes.

Putting it in the front matter is more user-friendly I think.

1 Like

Hi!

I almost crossposted this with @frjo. Well, I’ll post my text anyway.


There is not a single answer to that:

1

Your about page can have an individual layout: Create a template /layouts/about.html and put

---
layout: about
…
---

in your about.md.

Your about layout may contain the latest blog posts, an image gallery, and more. Only the ‘easily editable’ content goes into your markdown file.

2

You can add shortcodes to your about.md. Codes like {{< gallery src="my-gallery" >}} do not disturb much.

3

You can add a class to body and style everything very individually:

<body{{ if eq .URL "/about/" }} class="about"{{ end }}>
…

4

You can combine markdown and HTML. This may be more disturbing to editors.

5

You can use the <style> tag within your about.md. Style within body is now valid.

you put some content in a diffrent file - for the dumb users :wink:
use this in your template

Putting content in front matter seems great, I’ll give it a try.

The shortcodes seems great too because then I don’t have to put a lot of text in my frontmatter. I don’t know much about short codes, I’ll do some research.

EDIT: It looks like putting content in frontmatter is a bad idea because of unpredictable <p> tags. I’ll check out the shortcodes method instead.

The above is deprecated and bound to be removed in a future version of Hugo. Instead of .URL use .Permalink or .RelPermalink

1 Like