Text fields in content items

This might be a silly question, but nonetheless. I come from a Drupal approach and in Drupal it is common to add ‘fields’ to a content type. E.g. when you have an ‘article’, you might define a text field with a max character of e.g. 12 for a tag line of the article, a subtitle for the article, a summary, the actual content, an image… all defined in various fields.
Or suppose you have a ‘profile’ page, where you list the names, their interest (e.g. text field), their expertise (text field), their role in the company (text field)…

In HUGO I understood that one has a content with archetypes, and one can define some front matter where you could add taxonomie values. But the ‘content’ itself I can not understand how to organize this in e.g. the ‘field’ for interests, a field for expertise…
As far as I understand this is not directly possible, for after the front matter, the rest is ‘content’ as a bulk content section.

Is this correct or have I missed something in the doc?

You either missed shortcodes and scratch or you did not think about using those two for this :slight_smile:

A quick read of the two pages, still did not made me think using these for the use case I had :grinning:

But since you sound quite convincing, I suppose there is some truth in it. So will check it out. Thanks.

You can add any parameters you like to a posts frontmatter. These can then be displayed in your theme.

I think this is the closest you get to “fields” in Hugo.

2 Likes

I thought of parameters indeed. This might do the trick.

Found it sort of clunky, but what I ask might not be a common thing. I looked on how to style in parameters (aka add html such as <br> <i> or even classes to style it further in the lack of a wysiwyg editor’. Pointers would be very much appreciated.

Thanks for the reply.

+1 for using front-matter to define your custom fields. I work mostly with Craft which, like Drupal, has the concept of assignable fields with custom parameters to create content types. You can’t do this in Hugo directly, as far as I know.

The ‘content’ of each post/page/section is just markdown, you can’t really attach any pre-defined attributes or restrictions.

However, what you can do is control the way in which the front-matter fields are populated, which will give you control over the data entered there. This is exactly what I do as I build systems for normal users, not developers, who don’t even know what Markdown is. For smaller projects I use Netflify CMS but there are plenty of other similar projects. You define the field types per content type, and what content types are available to users.

Pretty sure you should be able do this with Drupal too, but it may be overkill. Using a CMS to enter conent ensures that it is of the type expected in your templates, then let Hugo do the rest.

This is a shot from my posts collection, as seen in Netlify CMS

Thanks for the reply.

At least I know I was not all to far off ‘a’ solution.