How to add the author name?

I also want to add the author name to the posts.

What should I do for that?

should be pretty easy, just add front matter to the post - author: Bob Smith and then in the layout you can do {{page.author}} you could also test to see if it exists by doing an if:

{% if page.author %}Written by: {{page.author}}{% endif %}

1 Like

Will this code work?

{% if page.author %}
  {% include author/{{page.author}}.html %}
{% endif %}

If we have lots of authors and we want to include a file specific to the author name.

AND

If we add the author: -name-, then will it also show up in the RSS feed?

2 Likes

That should work. You could also do the following:

---
author: 'Author Name'
---

{% include author-bio.html name: page.author %}

Then you could deal with the logic inside the partial

1 Like