hey guys, new to Hugo but loving it so far. I noticed the new docs (which were much easier to learn from) were taken down recently. Any way to see them again?
Also, I am trying to figure out how to achieve an author landing page with a collection of all that author’s posts in Hugo (like this - https://next.smashingmagazine.com/author/vitaly-friedman/ )
I have no idea where to begin - Is this a custom taxonomy, or a new type of “post” page? Any code examples would be super helpful. I’d also want to generate a list of authors on the sidebar with photos
I haven’t really looked at this (only started a few weeks ago myself), but I guess one way would be to create an author taxonomy, and then assign an author on each post that way. You could then create an _index.md file for each taxonomy entry to add author bio details to the page \ style as appropriate in the taxonomy.html file.
There seems to be a longer discussion here about it: [SOLVED] Multiple Authors w/ Own Article List (site.com/authors/author-name/article.md)
Would be interested for other opinions on this, but a few searches seem to only reveal the above.
Awesome, I’ll start here! Thanks
Yeh, I am not so sure I would follow the ideas in that link I posted (after re-reading it, it seems more complicated). I think my suggestion is a simple one, and the direction I would probably go if I was to implement.
Happy for others to chime in on their recommendations though.
Hm, if you have a little bit of time, can you give me a basic code example of your suggestions?
I suppose I’d want to define the author of a post on the frontmatter. Where would I place the _index.md for each author’s custom bio? Would it be layout/authors/joe/_index.md?
Sorry, I am short of time to build anything out for you.
However, treat the author exactly like a category - samples found in this section: http://gohugo.io/taxonomies/overview/
Yes, you have the correct place for index.md (note the "" ) and you will need to create the directory.
Hope that helps.
Edit- forums seem to strip out the underscore.
Thanks Jonathan. Will respond if I have additional questions. Appreciate the support
Yeh, one thing I haven’t thought about is displaying author bio details (apart from the name) on the article page itself, and where my knowledge gets a little sketchy (i.e. it would take me a bit of time to work out).
yeah, what I have so far is I can display the author’s name on the article, and on the sidebar, I can display all authors (just their name). I have to figure out how to display their photos. Also, _index.md doesn’t seem to be working for me. Not sure if I have it in the right place or missing some context, but just putting random words in _index.md for “joe” doesn’t show up.
I think you have to define fields in the front matter of the _index.md, and reference those fields in the templates specifically. I know this works, as I have utilized this myself for other things.
I think what I am going to do is to create a new repo over the weekend, and see if I can build something out.
My knowledge is lacking a little to advise off the top of my head. I will try and post the public repo when I am done. This is something I ought to implement myself anyway.
Thanks Jonathan! I’ll keep digging in the meantime but would love to see a working implementation
I just noticed on the post I linked in my first reply that rdwatters had the same idea (I didn’t quite read the last few entries )[quote=“rdwatters, post:15, topic:5837”]
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.
[/quote]
So I think we are on the right lines, just need to work out how to access the front matter in the _index.md file in this scenario.
Yeah, that’s the approach I’m trying to take. I made the taxonomy, added the authors to the frontmatter, and that’s working. the _index.md stuff worked by adding {{.content}} to the layouts/post/_index.md, but with the custom taxonomy (/layout/taxonomy/something) it doesn’t seem to be working just yet.
Try this in your template:
{{ range .Params.categories }}
{{$.Params.frontmattervariable}}
{{ end }}
Obviously replacing categories with author or whatever. Please let me know if it works for you. I think it will do it.
I think my problem is that I might be placing something in the wrong place, because neither the _index.md or the /layouts/taxonomy/alan.html is doing anything.
Looking at the hugo docs, I think I am doing this but no luck
Can you be very explicit with the paths I should be using for the _index.md and the template inside /layouts for adding additional stuff on top of an “alan” author?
content/authors/alan-roy/_index.md
For now, alter the single.html and add the following code somewhere:
{{ range .Params.authors }}
{{$.Params.bio}} // bio is a frontmatter variable in the author taxonomy _index.md
{{ end }}
(note if you just have _default layouts, change that single.html, otherwise alter the correct one for the content type.)
The code I mentioned adds the bio to the articles only, where that author has been assigned.
Also update your config.toml to add the author category:
[taxonomies]
tag = ""
category = "categories"
author = “authors”
Please let me know if that is not clear, and I will try to clarify further.
I just updated the index.md location in the preceding post (missed the s off).
FOr the taxoonomy page (i.e author page for each individual author), I have only so far updated the taxonomy.html in the _default.
This won’t really be a good idea for an author, as it will need to be unique (i.e. not change your usual category pages).
According to the docs: https://gohugo.io/templates/list/
/layouts/taxonomy/SINGULAR.html (e.g. /layouts/taxonomy/topic.html)
/layouts/_default/taxonomy.html
/layouts/_default/list.html
/themes/THEME/layouts/taxonomy/SINGULAR.html
/themes/THEME/layouts/_default/taxonomy.html
/themes/THEME/layouts/_default/list.html
so I would guess:
/layouts/taxonomy/author.html
is the correct place.
On this template, you can add params in the usual way. ie.:
{{ .Params.bio }}
Okay! I got the _index.md to render for the individual page, and defined the taxonomy template inside /taxonomy/, so everything is so far working. I actually had it right for a while but needed to restart Hugo for some reason. Now I have to dig deeper to figure out how to map a single frontmatter author to its relevant bios, photo url, etc.
Thank you! I may ask more questions as I keep going, but super appreciate it!