I'm new to jekyll. I imported content over from my WordPress site to jekyll and plan to use github pages for now.
The process went relatively smooth except for some author data displaying in my posts, next to the date. It looks like this:
{"login"=>"admin", "email"=>"[email protected]", "display_name"=>"John Doe", "first_name"=>"John", "last_name"=>"Doe"}
My post .html files have this in them:
author:
login: admin
email: [email protected]
display_name: John Doe
first_name: John
last_name: Doe
How do I modify the theme to display these fields properly? I'm using the minima theme currently.
In Jekyll, the author
is supposed to be a simply list, by having an object in this field, you end up with your result.
Of course, it all depends what you want to do with those data, you could go by:
Either, changing your font matter in your posts:
author:
- John Doe
Or, you could also alter the layout _layouts/post.html Around the line 20, you could change:
{%- if page.author -%}
• {% for author in page.author %}
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
<span class="p-author h-card" itemprop="name">{{ author }}</span></span>
{%- if forloop.last == false %}, {% endif -%}
{% endfor %}
{%- endif -%}</p>
to:
{%- if page.author -%}
•
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
<span class="p-author h-card" itemprop="name">{{ page.author.display_name }}</span>
</span>
{%- endif -%}</p>
Or even go with any flavour of this:
{%- if page.author -%}
•
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
<span class="p-author h-card" itemprop="name">
<a href="mailto:{{ page.author.email }}">
{{ page.author.display_name }} [{{ page.author.first_name }} {{ page.author.last_name }} — {{ page.author.login }}]
</a>
</span>
</span>
{%- endif -%}</p>