[SOLVED] Multiple Authors w/ Own Article List (site.com/authors/author-name/article.md)

In config.toml (currently the 2nd user is commented out, but you can define as many authors that contribute on your site)

[params.authors]
[params.authors.hash]
    name = "Hash Borgir"

    bio = "Hash is a Software Developer and generally a tech geek and computer nerd. He also consumes massive quantities of Cannabis and takes extremely deep journeys inwardly, meditates, explores the Universe within."

    location = "Colorado, USA"
    email = ""
    twitter=  "HashBorgir"
    image = "/images/authors/Hash_Borgir/user.jpg"
    instagram = "hashborgir"

#[params.authors.guest]
#    name = "Guest Writer"
#
#   bio = "Guest author profile. No bio. "
#
#    location = "Colorado, USA"
#    email = ""
#    twitter=  ""
#    image = "/images/authors/Guest/gust.jpg"
#    instagram = ""

And then in my theme I have this file

/layouts/partials/widgets/authors.html

`
{{ $baseurl := .Site.BaseURL }}

Resident Authors

<div class="panel-body">
    <div class="authors-list">
        {{ range $name, $items := .Site.Params.authors }}
            {{ range $key, $val := $items }}
                {{ if eq $key "name" }}
                <p><a href="{{ $baseurl }}authors/{{ $val | urlize | lower }}"><i class="fa fa-tags"></i> {{ $val }}</a>
                </p>
                {{ end }}
            {{ end }}

        {{ end }}
    </div>
</div>
`

and then in config.toml

[taxonomies]
author="authors"

then make a new folder called

/content/authors/

and then create a folder for the author name for example /content/authors/hash-borgir/my_article.md

And in the front matter of your article, you must have:

authors = "hash-borgir"
author="hash"

The context of .Params.author will go into the array of .Site.Params.authors and pull the relevant author and display him, so we specify his name = “Hash Borgir” so we make a slug of it, authors = “hash-borgir”

Now you can have site.com/authors/hash-borgir or site.com/authors/guest or site.com/authors/jilly-milly

and their own individual articles wil only show up in their name.

you must also create

/layout/taxonomy/author.html

and in this file you must put: .Pages variable but not .Site.Pages or something

and you can refer to your author as this:

{{$author := index .Site.Params.authors (.Params.author) }}

and now you can refer to your author fields from config.toml as

$author.name or $author.twitter etc.

Thank you, I will make a blog post from this soon. :slight_smile:

1 Like

It seems like you don’t need taxonomy/author.html.

It shows the article list w/o having to create a taxonomy page for authors. I might have done something probably wrong, but multiple authors are working on my end, each with their own articles list.

I am still not fully understanding the taxonomy bit.

Hi @Hash_Borgir; is the idea that you’re trying to create content/metadata to each of the authors? Trying to get a better grip on your desired output:)

I’m currently got it working for https://PsychedelicsDaily.com

It already works on my old site https://stoned.io

https://stoned.io/authors/yash-akasha/
https://stoned.io/authors/jasmine-miller/
https://stoned.io/authors/hash-borgir/

I have it also working on https://PsychedelicsDaily.com but I don’t more than one author. I created a test author to test, and it works.

I can maybe demo that later.

P.S.


Currently both work, but I have disabled the guest-writer on the live site.

[params.authors.guest]
name = “Guest Writer”

[params.authors.hash]
name = “Hash Borgir”

As you can see, I am defining my authors taxonomy using the name.

EDIT: I have re-enabled the guest-writer user in the config.

If you go to any of the links, they should all be working to demo what I’m trying to do.

So you see my sidebar, it lists Authors

And it will list as many authors as I have defined in config.toml, created a content/authors/author-name folder for their articles, and defined my taxonomy.

Now, what I’d like to do, is have an author profile page, so that if you go to https://psychedelicsdaily.com/authors/ it will display a custom template for the authors taxonomy, so I can customize that page.

I tried to add /layouts/taxonomy/author.html but that file doesn’t effect site.com/authors/ taxonomy.

What am I doing wrong?

Do you need further explanation of what I am doing?

Actually there seems to be another problem:

When I go to https://psychedelicsdaily.com/news/

Which uses /layout/default/list.html

and inside this list.html template

I am using this:

{{ $paginator := .Paginate .Pages}}

I have
/content/news/articles here.md
/content/authors/hash-borgir/articles here.md
content/authors/guest-writer/articles here.md

I am using the hugo-universal-theme and in this theme, there are some .md files like contact.md which exists inside content/contact.md (custom menu link), so to counter that, I added a frontmatter to my articles called type=“article” so contact.md won’t be displayed if I use .Pages or .Site.Pages

If I change to .Site.Pages or {{ $paginator := .Paginate (where .Site.Pages “Type” “article”) }} it still doesn’t work. If I use just .Pages, still doesn’t work. by work, I mean pull all the articles w/ a specific front matter option.

.Data.Pages is the same as .Pages.

What can I use in /layout/list.html so that it will display content articles from

/content/news
/content/authors/arbitrary-name/

+++
description = "Test article"
type = "article"
banner = “img/banners/guest-author.jpg"
author = “guest"
news_keywords = [””]
images = [“https://i.imgur.com/”]
categories = [“Psychedelics”]
date = "2017-03-18T10:14:30-06:00"
title = "Test Article Being Tested on the things which need to be tested upon"
authors = "guest-writer"
tags = [“Test”]
draft = “false”
+++

Here’s the front matter.

Now in the main site homepage template, it is referencing recent_posts.html partial, and in that partial, {{ $posts := .Paginate (where .Site.Pages “Type” “article”) }} seems to pull ALL the articles on the website which have frontmatter type=“article”

This {{ $posts := .Paginate (where .Site.Pages “Type” “article”) }} works on homepage template, index.html, and partials/recent_posts.html, but if I use this in list.html, it only renders articles from the /content/news/ directory

So everything is working except for the fact that when I go to When I go to https://psychedelicsdaily.com/news/ The Test article which shows up on the site main homepage, it doesn’t show up in this site.com/news link.

How can I get to display all the articles, who only have this front matter set (type=“article”)?

Does this make sense?

Little more goofy stuff, haha, check this out:

If I edit /layouts/_default/list.html

{{ $paginator := .Paginate (where .Site.Pages “Type” “article”) }}

(Note change to .Site.Pages and then filter it, if you then go to site.com/news, it will list ALL the articles, which work fine.

But… now if you go to any of the tags taxonomies, it will show all the articles from any tag, not just the tag I want.

Won’t show only MDMA tagged articles, it will show all the articles with all the tags.

{{ $paginator := .Paginate (where .Pages “Type” “article”) }}

If I change to .Pages and then filter, tags taxonomies start to work as expected, but then the site.com/news will only list articles in /content/news. I’d like it to show /content/news and /content/authors/author-name/

See what I mean?

{{ $paginator := .Paginate (where .Pages “Type” “article”) }} <- this works to list all the articles.

If I use a conditional
{{ if eq .Kind “section” }}
{{ $paginator := .Paginate (where .Pages “Type” “article”) }}

                {{ else if eq .Kind "taxonomy"}}
                    {{ $paginator := .Paginate .Pages}}

                {{ range $paginator.Pages }}

nothing is rendered at /news, but the taxonomies work fine.

Any idea why?

{{ if ne .Kind "taxonomy" }}
{{ $paginator := .Paginate (where .Site.Pages "Type" "article") }}
{{ range $paginator.Pages }}

                        <section class="post">
                            <div class="row">
                                <div class="col-md-4">
                                  <div class="image">
                                      <a href="{{ .Permalink }}">
                                          {{ if .Params.banner }}
                                          <img src="{{ .Site.BaseURL}}{{ .Params.banner }}" class="img-responsive" alt="">
                                          {{ else }}
                                          <img src="{{ .Site.BaseURL}}img/placeholder.png" class="img-responsive" alt="">
                                          {{ end }}
                                      </a>
                                  </div>
                                </div>
                                {{$author := index .Site.Params.authors (.Params.author) }}
                                <div class="col-md-8 post-meta">
                                    <h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
                                    <div class="clearfix">
                                        <p class="author-category">
                                          {{ if isset .Params "author" }}
                                          By:
                                          <a class="" href="{{$baseurl}}authors/{{ $author.name | urlize }}/">{{$author.name}}</a>
                                          {{ end }}

                                        Tags:
                                        {{ range $index, $tag := .Params.tags }}
                                        <a class="" href="{{$baseurl}}tags/{{ $tag | urlize }}/">#{{ $tag }}</a>,
                                        {{ end }}

                                          {{ if isset .Params "categories" }}
                                          {{ if gt (len .Params.categories) 0 }}
                                          in <a href="{{ $.Site.BaseURL }}categories/{{ index .Params.categories 0 | urlize | lower }}">{{ index .Params.categories 0 }}</a>
                                          {{ end }}
                                          {{ end }}

                                        </p>
                                        <p class="date-comments">
                                            <a href="{{ .Permalink }}"><i class="fa fa-calendar-o"></i> {{ .Date.Format .Site.Params.date_format }}</a>
                                        </p>
                                    </div>
                                    <p class="intro">{{ slicestr .Summary 0 200 | markdownify}}...</p>
                                    <p class="read-more"><a href="{{ .Permalink }}" class="btn btn-template-main">Continue reading</a>
                                    </p>
                                </div>
                            </div>
                        </section>
                        {{ end }}
{{ else }}
{{ $paginator := .Paginate .Data.Pages}}
{{ range $paginator.Pages }}

                        <section class="post">
                            <div class="row">
                                <div class="col-md-4">
                                  <div class="image">
                                      <a href="{{ .Permalink }}">
                                          {{ if .Params.banner }}
                                          <img src="{{ .Site.BaseURL}}{{ .Params.banner }}" class="img-responsive" alt="">
                                          {{ else }}
                                          <img src="{{ .Site.BaseURL}}img/placeholder.png" class="img-responsive" alt="">
                                          {{ end }}
                                      </a>
                                  </div>
                                </div>
                                {{$author := index .Site.Params.authors (.Params.author) }}
                                <div class="col-md-8 post-meta">
                                    <h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
                                    <div class="clearfix">
                                        <p class="author-category">
                                          {{ if isset .Params "author" }}
                                          By:
                                          <a class="" href="{{$baseurl}}authors/{{ $author.name | urlize }}/">{{$author.name}}</a>
                                          {{ end }}

                                        Tags:
                                        {{ range $index, $tag := .Params.tags }}
                                        <a class="" href="{{$baseurl}}tags/{{ $tag | urlize }}/">#{{ $tag }}</a>,
                                        {{ end }}

                                          {{ if isset .Params "categories" }}
                                          {{ if gt (len .Params.categories) 0 }}
                                          in <a href="{{ $.Site.BaseURL }}categories/{{ index .Params.categories 0 | urlize | lower }}">{{ index .Params.categories 0 }}</a>
                                          {{ end }}
                                          {{ end }}

                                        </p>
                                        <p class="date-comments">
                                            <a href="{{ .Permalink }}"><i class="fa fa-calendar-o"></i> {{ .Date.Format .Site.Params.date_format }}</a>
                                        </p>
                                    </div>
                                    <p class="intro">{{ slicestr .Summary 0 200 | markdownify}}...</p>
                                    <p class="read-more"><a href="{{ .Permalink }}" class="btn btn-template-main">Continue reading</a>
                                    </p>
                                </div>
                            </div>
                        </section>
                        {{ end }}
{{ end }}

I had to duplicate some code, but it works now as expected.

There must be a better way to do this, if there is, please advise. :slightly_smiling:

Finally. Jeez. It’s midnight now, I’ve been at this all day. Finally nailed it. Seems to work, changes are live on the site, please test if you want.

It is more convenient to add the authors in front matter as an array.

authors:
  - One
  - Two
  - Etc
{{ $baseurl := .Site.BaseURL }}
{{ with .Params.authors }}
    <p>Автор{{ if gt (len .) 1 }}ы{{ end }}:
    {{ range  $i, $kw := . }}{{ if $i }}&bullet;{{ end }}
        {{ if isset $.Site.Data.names . }}
        {{ $dtitle := (index $.Site.Data.names .) }}
        <a href="{{ $baseurl }}authors/{{ . | urlize }}/" rel="author">{{ index $dtitle.shortname }}</a>
        {{ else }}
        <a href="{{ $baseurl }}authors/{{ . | urlize }}/" rel="author">{{ . }}</a>
        {{ end }}
    {{ end }}</p>
{{ end }}

Result

1 Like

Ahh, you’re using the “.Data” “/data”/ folder. Interesting. I don’t quite understand why define author in front matter.

Oh, you’re doing multiple authors PER post?! Nice. I didn’t think of that. But on my end, I don’t have authors colloborating, but if they do, multiple authors showing would be nice.

Thanks for another idea, brother. Cheers.

@Hash_Borgir sorry for the delay: different time zones. You have a lot of different posts on here now, but this is the thought I had last night in terms of taxonomies: why not keep it simple and create an author taxonomy, add one (or more) authors in your front matter, and then if you want to add content/metadata for any individual author, you do so using an _index.md file in taxonomy/author folder. Then you don’t need to use a data file or create these complex partials.

I think the big shift is the addition of the _index.md (note the underscore is important!) since you and I last chatted on here a few versions back with Hugo.

I would really like to understand what all you’re talking about. This new way to organize using some taxonomy _index is new to me and I’ll have to look into it.

I don’t mind redoing my site if it offer better scalability in future.

Thank you very much for your time and effort. :slightly_smiling:

Hi Mikhail,
your solution may be suited for me, multiple authors for a single post.
What I can not achieve is to retrieve author infos in his dedicated page like it seems you did here: http://pokrovsky.newgod.su/authors/корзун/

I wish I could print both front matter infos and description in his markdown file.

In my layout/taxonomy/author.html I tried with {{ .Params.featured_image }} where “featured_image” is a custom properties in the front matter of mine but it is not working.

How did you get those infos?

Thank you!

My template \layouts\taxonomy\author.html. In order for this template to work, should be enable options pluralizeListTitles: false and preserveTaxonomyNames: true in the config.yaml.

{{ $yaml := index .Site.Data.names .Title }}
    <div class="container">
        <div class="row">
            <div class="sixteen columns">
            <section>
                <header><span class="li-article-title"><a href="/authors/">Указатель авторов</a> &gt;&#32;</span>
                    {{ if $yaml }}
                        <h1 class="li-article-title">{{ with $yaml.penname }} {{ . }} {{ else }} {{ $yaml.fullname }} {{ end }}</h1>
                    {{ else }}
                        <h1 class="li-article-title">{{ .Title }}</h1>
                    {{ end }}
                </header>
                <div class="ten columns li-right">
                    {{ if isset $.Site.Taxonomies.authors .Title }}
                        <h2>Автор писем и статей:</h2>
                        <ul class="li-article-list">
                          {{ range (index $.Site.Taxonomies.authors .Title).Pages }}
                              {{ .Render "li-no-author" }}
                          {{ end }}
                        </ul>
                    {{ end }}
                    {{ if isset $.Site.Taxonomies.recipients .Title }}
                      <h2>Получатель писем:</h2>
                      <ul class="li-article-list">
                        {{ range (index $.Site.Taxonomies.recipients .Title).Pages }}
                            {{ .Render "li-gost" }}
                        {{ end }}
                      </ul>
                    {{ end }}
                    {{ if isset $.Site.Taxonomies.persons .Title }}
                      <h2>{{ with $yaml.shortname }}{{ . }}{{ else }}{{ .Title }}{{ end }} упомянут(а) в статьях и письмах:</h2>
                      <ul class="li-article-list">
                        {{ range (index $.Site.Taxonomies.persons .Title).Pages }}
                            {{ .Render "li-gost" }}
                        {{ end }}
                      </ul>
                    {{ end }}
                </div>
        </section>
{{ if $yaml }}
    <div class="li-article-taxonomies five columns">
        {{ if fileExists (printf "static/images/persons/%s.jpg" $yaml.transname) }}
            <div class="row center">
                <img class="mi-one-imag-in-tax mi-shadow mi-radius" src="/images/persons/{{ $yaml.transname }}.jpg" alt="{{ $yaml.shortname }}">
            </div>
        {{ end }}
        {{ if fileExists (printf "static/images/persons/%s.png" $yaml.transname) }}
            <div class="row center">
                <img src="/images/persons/{{ $yaml.transname }}.png" alt="{{ $yaml.shortname }}">
            </div>
        {{ end }}
        {{ with $yaml.penname }} <strong>{{ . }}</strong> {{ end }}
        {{ with $yaml.nickname }} {{ . }} {{ end }}
        {{ with $yaml.years }} <p class="center"><b>{{ replaceRE "(-|—)" "–" . }}</b></p> {{ end }}
        {{ with $yaml.info }} {{ markdownify . }} {{ end }}
        {{ with $yaml.job }}<p><b>Место работы:</b> {{ . }}</p> {{ end }}
        {{ with $yaml.url }}<p><b>www:</b> <a href="{{ . }}" target="_blank">{{ replaceRE "^https?://(www.)?([^/]+).*" "$2" . }}</a></p> {{ end }}
    </div>
{{ end }}
        </div>
    </div>
    </div>

File with info about authors /data/names.yaml in template it called .Site.Data.names.

Введенский:
  fullname: Введенский Александр Иванович
  shortname: Введенский А. И.
  years: (1889-1946)
  job:
  transname: vvedenskij
  info: '— протоиерей, в обновленческом расколе — митрополит, один из лидеров обновленческого движения в Православной Российской Церкви в 1922—1946 годах.'
  url: 
  email:
Зевин:
  fullname: Зевин Владимир Яковлевич
  shortname: Зевин В. Я.
  years: (1918-1976)
  job:
  transname: zevin-vladimir
  info: '— историк, д-р ист. наук, секр. Бакинского горкома КПСС, зам. дир. ИМЭЛа, зав. Отделом ЦК КПСС (1966-1971), сын Я. Д. Зевина (ученика ленинской школы в Лонжимо)'
  url: http://litnasledstvo.ru/site/author/id/452
  email:

I have added a support in my blog website to manage multiple authors

  1. Associate each article with individual author
  2. Author’s name, picture and short description will be visible on each article
  3. Article list of individual author can be accessible using taxonomy