-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Open
Milestone
Description
I would like to have the ability to use .GitInfo in archetype templates to provide information about the author. It seems like .GitInfo is directly bound to the content file's git metadata, so this may not be a good candidate. But maybe there is another way to autopopulate information about author by using current git user. This will allow us to use author: {{ .GitInfo.AuthorName }} in archetype template frontmatter. There will be multiple authors for the project so I need information from git, not from config.toml
Example
Add author: {{ .GitInfo.AuthorName }} to archetypes/default.md
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
author: {{ .GitInfo.AuthorName }}
---Current behavior
We get an error.
$ hugo new test.md
Error: failed to execute archetype template: template: archetype.md:5:19: executing "archetype.md" at <.GitInfo.AuthorName>: can't evaluate field GitInfo in type *hugolib.archetypeFileData: template: archetype.md:5:19: executing "archetype.md" at <.GitInfo.AuthorName>: can't evaluate field GitInfo in type *hugolib.archetypeFileDataExpected behavior
New test.md content file is created
---
title: "Test"
date: 2023-04-18T16:15:43+07:00
draft: true
author: "John Doe"
---