Create a new webpage for each Taxonomy

My website has an authors taxonomy which lists all the authors of the website. The terms page show all the posts associated with each author.
Is it possible to create a template, say profile, which should be responsible for hosting the author’s profile. The data for the profile will be fetched through a file’s frontmatter.

Is it possible to do so using Hugo?

Yes, you can do it. I have done it for “series”.

Here is my sample to give you a starting point

@ju52 I tried creating a template posts.html.html in layouts/authors but it didn’t work. Accessing authors/<author>/posts gives 404 error.

Here’s my posts.html.html:

{{- define "main" -}}

<div class="universal-wrapper pt-3" style="margin-bottom: 1rem;">
  <h1>{{ printf "%s / Posts" $.Data.Term }}</h1>

<div class="universal-wrapper">
  {{ range }} 
    {{ if eq $.Params.view 1 }}
      {{ partial "li_list" . }}
    {{ else if eq $.Params.view 3 }}
      {{ partial "li_card" . }}
    {{ else }}
     {{ partial "li_compact" . }}
    {{ end }}
  {{ end }}
  {{ partial "pagination" . }}

{{- end -}}

You must make templates under layouts/authors/

terms.html.html is a template for a list of authors
list.html.html is a template for every author

Do you have a github repo?

Yes, this is my repo:

I already have the list and term templates there.

Hi there,

Do you mean that you want one author to have two pages published: one with list of content tagged to that author, and a second one with their profile? Like so:



authors/author-one/ => list of content tagged author-one
authors/author-one-profile/ => author profile

If so you might want to have a look at custom output formats, and perhaps create a custom one.

1 Like

you should understand the template lookup order.

The template layouts/authors/post* will never used, if you don’t set layout = “post” in the author content files.

Your files under /layouts will override the files under /themes/academic/layouts

I used {{ print "<!-- Template layouts/list.html" -->" }} in my template to analyse the used templates in my generated files.

@ju52 It seems that I hadn’t clearly explained my issue but @pointyfar guessed it correctly and his solution of using Custom Output Formats helped me.

For this, I’ve created a custom output format:

    baseName: posts
    mediaType: text/html
    notAlternative: true
    permalinkable: true
    isHTML: true
    noUgly: true

and I adjust the outputs slice in my author frontmatter to enable this output using layouts/authors/list.posts.html.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.