Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the different ways to configure authors #2494

Open
saikadaramakaisosjupita opened this issue Mar 16, 2024 · 5 comments
Open

Document the different ways to configure authors #2494

saikadaramakaisosjupita opened this issue Mar 16, 2024 · 5 comments

Comments

@saikadaramakaisosjupita
Copy link

saikadaramakaisosjupita commented Mar 16, 2024

Like using taxonomies, site Params, etc.

See https://discourse.gohugo.io/t/deprecation-warning-for-site-author-confusing-replacement-advice/48874

@jmooring
Copy link
Member

jmooring commented Mar 20, 2024

Example of using the authors taxonomy to handle site and page authors. Works fine for one or many authors.

git clone --single-branch -b hugo-forum-topic-48874 https://github.com/jmooring/hugo-testing hugo-forum-topic-48874
cd hugo-forum-topic-48874
hugo server

Files of interest:

  • content/authors/*
  • layouts/authors/term.html
  • layouts/partials/get-first-page-author.html
  • layouts/partials/get-first-site-author.html
  • layouts/partials/list-page-authors.html
  • layouts/partials/list-site-authors.html

See comments in partial headers for details.

This approach takes some time to setup, but is infinitely extensible.

Part of this is documented here:
https://gohugo.io/templates/taxonomy/#display-metadata

@saikadaramakaisosjupita
Copy link
Author

@jmooring I am assuming your comment means this will be documented eventually?

@jmooring
Copy link
Member

jmooring commented Apr 8, 2024

this will be documented eventually?

Yes, that's why the issue is open.

@BPowell76
Copy link

BPowell76 commented May 5, 2024

I don't understand what was wrong with using author in the frontmatter. As someone new to using Hugo this is frustrating and I see it as an unnecessary change.

@jmooring
Copy link
Member

jmooring commented May 5, 2024

Author

You can create an author front matter parameter. For example:

[params.author]
email = 'jdoe@example.org'
name = 'John Doe'

Then access the value from a template:

{{ .Params.author.name }}
{{ .Params.author.email }}

What you can't do (deprecated):

{{ .Author }}

Authors

You can create an authors front matter parameter. For example:

[[params.authors]]
email = 'jdoe@example.org'
name = 'John Doe'

[[params.authors]]
email = 'rsmith@example.org'
name = 'Robert Smith'

Then access the values from a template:

{{ range .Params.authors }}
  {{ .name }}
  {{ .email }}
{{ end }}

What you can't do (deprecated):

{{ .Authors }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants