Thank you for the tip! This is exactly I looked for. I’d like to share a possibility to generate humans.txt
based on your approach.
config.toml
:
# Possible 'Author' formats are:
#
# [author]
# name = 'John Doe'
# email = 'john@example.com'
# github = '@john_doe'
# location = 'Kyiv, Ukraine'
#
# OR
#
# [author]
# [author.john_doe]
# name = 'John Doe'
# email = 'john@example.com'
# github = '@john_doe'
# location = 'Kyiv, Ukraine'
# [author.jane_doe]
# name = 'Jane Doe'
# email = 'jane@example.com'
# github = '@jane_doe'
# location = 'Lviv, Ukraine'
[author]
name = 'John Doe'
email = 'john@example.com'
github = '@john_doe'
location = 'Kyiv, Ukraine'
layouts/index.humanstxt.txt
:
{{ with site.Author }}
{{- $author_type := (printf "%T" site.Author) }}
{{- if (or (eq $author_type "map[string]string") (eq $author_type "map[string]interface {}")) }}
/* TEAM */
{{ range $i, $member := site.Author }}
{{- if (eq (printf "%T" $member) "maps.Params") }}
{{- partial "team-member.html" (dict "context" . "member" $member) -}}
{{- else if (eq (printf "%T" $member) "string") }}
{{- partial "team-member.html" (dict "context" . "member" site.Author) -}}
{{- break -}}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
/* SITE */
Last update: {{ now.Format "2006/01/02" }}
Language: {{ range $i, $l := site.Languages }}{{ if $i }}, {{ end }}{{ .LanguageName }}{{ end }}
Doctype: HTML5
Standards: HTML5, CSS3, Open Graph protocol, Schema.org
Components: Hugo, jQuery, Ed Theme
layouts/partials/team-member.html
:
Author: {{ $.member.name | default "-" }}
Contact: {{ $.member.email | default "-" }}
GitHub: {{ $.member.github | default "-" }}
From: {{ $.member.location | default "-" }}
Output:
/* TEAM */
Author: Jane Doe
Contact: jane@example.com
GitHub: @jane_doe
From: Lviv, Ukraine
Author: John Doe
Contact: john@example.com
GitHub: @john_doe
From: Kyiv, Ukraine
/* SITE */
Last update: 2022-05-15
Language: English
Doctype: HTML5
Standards: HTML5, CSS3, Open Graph protocol, Schema.org
Components: Hugo, jQuery, Ed Theme
Note, due to {{- break -}}
in layouts/index.humanstxt.txt
you have to use Hugo >= 0.95.0. For more see: