# .htaccess, humans.txt with template logic

**URL:** <https://discourse.gohugo.io/t/htaccess-humans-txt-with-template-logic/27624>\
**Category:** tips & tricks\
**Created:** [August 16, 2020, 3:59am UTC](https://discourse.gohugo.io/t/htaccess-humans-txt-with-template-logic/27624 "2020-08-16T03:59:58Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![egrep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/egrep/32/21832_2.png) [@egrep](https://discourse.gohugo.io/u/egrep)\
**Post date:** [May 15, 2022, 9:30am UTC](https://discourse.gohugo.io/t/htaccess-humans-txt-with-template-logic/27624/4 "2022-05-15T09:30:38Z")

</div>

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`:**

```auto
# 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`:**

```auto
{{ 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`:**

```nohighlight

    Author: {{ $.member.name | default "-" }}
    Contact: {{ $.member.email | default "-" }}
    GitHub: {{ $.member.github | default "-" }}
    From: {{ $.member.location | default "-" }}

```

Output:

```auto
    /* 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:

- [`continue` statement in `range` block](https://discourse.gohugo.io/t/continue-statement-in-range-block/19015)
- [text/template: add break and continue support · Issue #20531 · golang/go · GitHub](https://github.com/golang/go/issues/20531)
- [Release v0.95.0 · gohugoio/hugo · GitHub](https://github.com/gohugoio/hugo/releases/tag/v0.95.0)

---

_[View the full topic](https://discourse.gohugo.io/t/htaccess-humans-txt-with-template-logic/27624)._
