Enhancement: Define a base template for a content type #279

Closed
opened 2026-10-05 02:37:26 +02:00 by adam · 6 comments
Owner

Similar to what we have in the template functionality, it would be useful to have a template that can be mapped to a content type for the initial content generation. That way, you can create content with predefined content.

Right now when creating content with the content type functionality, you will always start from a blank file.

Similar to what we have in the template functionality, it would be useful to have a template that can be mapped to a content type for the initial content generation. That way, you can create content with predefined content. Right now when creating content with the content type functionality, you will always start from a blank file. <!-- github-sync-id:1266389565 -->
adam closed this issue 2026-10-05 02:37:26 +02:00
Author
Owner

Yep, this is a must-have, and would keep the benefits of templates and get rid of them as an additional option that has confused users.

Yep, this is a must-have, and would keep the benefits of templates and get rid of them as an additional option that has confused users. <!-- github-comment-id:1151761939 -->
Author
Owner

This would also be a cool feature for using templates from The Good Docs Project in a starter kit.
https://thegooddocsproject.dev/

This would also be a cool feature for using templates from The Good Docs Project in a starter kit. https://thegooddocsproject.dev/ <!-- github-comment-id:1151763046 -->
Author
Owner

Yep, this is a must-have, and would keep the benefits of templates and get rid of them as an additional option that has confused users.

Great! Will add this to the v8.0.0 roadmap.

In the current version, the functionality of creating content by templates got disabled by default.

> Yep, this is a must-have, and would keep the benefits of templates and get rid of them as an additional option that has confused users. Great! Will add this to the v8.0.0 roadmap. In the current version, the functionality of creating content by templates got disabled by default. <!-- github-comment-id:1152041066 -->
Author
Owner

The new template property got introduced to the content type. It requires you to specify the path to the template you want to use.

If a template is defined, the front matter and content will be taken as the base. While processing the content type fields, the front matter defined in the template will be overridden. It is not mandatory to define front matter in this case, but you certainly can do it.

Configuration of the content type looks as follows:

{
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "template": "[[workspace]]/.frontmatter/templates/article.md",
      "fields": [...]
    }
}

The new `template` property got introduced to the content type. It requires you to specify the path to the template you want to use. If a template is defined, the front matter and content will be taken as the base. While processing the content type fields, the front matter defined in the template will be overridden. It is not mandatory to define front matter in this case, but you certainly can do it. Configuration of the content type looks as follows: ``` { "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": false, "template": "[[workspace]]/.frontmatter/templates/article.md", "fields": [...] } } ``` <!-- github-comment-id:1152141589 -->
Author
Owner

Can the path to the template be to the hugo archetypes folder?

As you indicated, the entirety of the pre-existing frontmatter in the archetype will be ignored, and only the content portion will remain for the template?

Is part of the intention to do away with the previous FM template method in favor of content type method?

When the new md file is generated using an archetype in hugo, hugo functions in the archetype execute and can return values on generation. Is this also possible with contentTypes?

Can the path to the template be to the hugo archetypes folder? As you indicated, the entirety of the pre-existing frontmatter in the archetype will be ignored, and only the content portion will remain for the template? Is part of the intention to do away with the previous FM template method in favor of content type method? When the new md file is generated using an archetype in hugo, hugo functions in the archetype execute and can return values on generation. Is this also possible with contentTypes? <!-- github-comment-id:1152437794 -->
Author
Owner

Can the path to the template be to the hugo archetypes folder?

Yes, you should be able to specify any folder in your workspace. In you case, it could be [[workspace]]/archetypes/post.md.

As you indicated, the entirety of the pre-existing frontmatter in the archetype will be ignored, and only the content portion will remain for the template?

The front matter from the template will not be processed during generation. It will remain in place and if there are matching fields in the content type, it will update it accordingly.

For instance, if you have a title in the template and also in the content type. The value of the title field will be updated in the content by what is defined in the content-type field.

Is part of the intention to do away with the previous FM template method in favor of content type method?

Content types in FM provide a lot more flexibility for the creation and management of the metadata of the page. This is what was lacking in our first template approach. The reason for this change is to combine both so that you can have a quick start when you are creating new articles with a predefined structure or any other content that would be required.

When the new md file is generated using an archetype in hugo, hugo functions in the archetype execute and can return values on generation. Is this also possible with contentTypes?

In FM this is done from the default property and the available placeholders (https://frontmatter.codes/docs/content-creation/placeholders#placeholders).

We have a couple of them available. If there are any missing, feel free to let us know and we'll try to make them available in the next release(s).

> Can the path to the template be to the hugo archetypes folder? Yes, you should be able to specify any folder in your workspace. In you case, it could be `[[workspace]]/archetypes/post.md`. > As you indicated, the entirety of the pre-existing frontmatter in the archetype will be ignored, and only the content portion will remain for the template? The front matter from the template will not be processed during generation. It will remain in place and if there are matching fields in the content type, it will update it accordingly. For instance, if you have a title in the template and also in the content type. The value of the title field will be updated in the content by what is defined in the content-type field. > Is part of the intention to do away with the previous FM template method in favor of content type method? Content types in FM provide a lot more flexibility for the creation and management of the metadata of the page. This is what was lacking in our first template approach. The reason for this change is to combine both so that you can have a quick start when you are creating new articles with a predefined structure or any other content that would be required. > When the new md file is generated using an archetype in hugo, hugo functions in the archetype execute and can return values on generation. Is this also possible with contentTypes? In FM this is done from the `default` property and the available placeholders (https://frontmatter.codes/docs/content-creation/placeholders#placeholders). We have a couple of them available. If there are any missing, feel free to let us know and we'll try to make them available in the next release(s). <!-- github-comment-id:1153741348 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#279