Skip to content
This repository was archived by the owner on Jul 25, 2025. It is now read-only.

Commit 733067b

Browse files
committed
Enhance author schema data in articles, authors, FAQs, and terms views
- Updated author information in the JSON-LD schema for articles, FAQs, and terms to include author URL and job title. - Added schema data for authors on the authors index and show pages, improving SEO and content attribution. - Ensured all author-related data is compacted for cleaner output. This improves the visibility of authors in search engines and enhances user navigation to author profiles.
1 parent 17ced09 commit 733067b

5 files changed

Lines changed: 62 additions & 7 deletions

File tree

app/views/articles/show.html.erb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
"dateModified": @article.updated_at.iso8601,
1515
"author": {
1616
"@type": "Person",
17-
"name": @article.author_name.presence || "Maybe Finance"
18-
},
17+
"name": @article.author&.name || @article.author_name.presence || "Maybe Finance",
18+
"url": @article.author ? author_url(@article.author) : nil,
19+
"jobTitle": @article.author&.position
20+
}.compact,
1921
"publisher": {
2022
"@type": "Organization",
2123
"name": "Maybe Finance",

app/views/authors/index.html.erb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
<%
22
title "Personal Finance Authors"
33
description "Meet the experts behind our personal finance content."
4+
5+
content_for :schema_data do
6+
authors_list_schema = {
7+
"@context": "https://schema.org",
8+
"@type": "ItemList",
9+
"name": "Personal Finance Authors",
10+
"description": "Meet the experts behind our personal finance content.",
11+
"itemListElement": @authors.map.with_index do |author, index|
12+
{
13+
"@type": "ListItem",
14+
"position": index + 1,
15+
"item": {
16+
"@type": "Person",
17+
"name": author.name,
18+
"url": author_url(author),
19+
"jobTitle": author.position,
20+
"description": author.bio,
21+
"image": author.avatar_url
22+
}.compact
23+
}
24+
end
25+
}
26+
27+
concat(tag.script(authors_list_schema.to_json.html_safe, type: "application/ld+json"))
28+
end
429
%>
530
<div class="bg-contain bg-[left_0_top_0] bg-no-repeat" style="background-image: url(<%= asset_path('articles-bg.svg') %>)">
631
<div class="max-w-[1100px] mx-auto">

app/views/authors/show.html.erb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
<%
22
title @author.name
33
description @author.bio || "Read articles and content by #{@author.name}"
4+
5+
content_for :schema_data do
6+
author_schema = {
7+
"@context": "https://schema.org",
8+
"@type": "Person",
9+
"name": @author.name,
10+
"url": author_url(@author),
11+
"jobTitle": @author.position,
12+
"description": @author.bio,
13+
"image": @author.avatar_url,
14+
"sameAs": @author.social_links&.values&.compact || [],
15+
"worksFor": {
16+
"@type": "Organization",
17+
"name": "Maybe Finance",
18+
"url": "https://maybefinance.com"
19+
}
20+
}.compact
21+
22+
concat(tag.script(author_schema.to_json.html_safe, type: "application/ld+json"))
23+
end
424
%>
525
<div class="bg-contain bg-[left_0_top_0] bg-no-repeat" style="background-image: url(<%= asset_path('articles-bg.svg') %>)">
626
<div class="max-w-[1100px] mx-auto">

app/views/faqs/show.html.erb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616
"acceptedAnswer": {
1717
"@type": "Answer",
1818
"text": strip_tags(@faq.answer),
19-
"dateCreated": @faq.created_at.iso8601
20-
}
19+
"dateCreated": @faq.created_at.iso8601,
20+
"author": @faq.author ? {
21+
"@type": "Person",
22+
"name": @faq.author.name,
23+
"url": author_url(@faq.author),
24+
"jobTitle": @faq.author.position
25+
}.compact : nil
26+
}.compact
2127
}
2228
}
2329

app/views/terms/show.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
"headline": @term.name.presence || "#{@term.name} meaning in personal finance",
2020
"description": article_description,
2121
"author": {
22-
"@type": "Organization",
23-
"name": "Maybe"
24-
},
22+
"@type": @term.author ? "Person" : "Organization",
23+
"name": @term.author&.name || "Maybe",
24+
"url": @term.author ? author_url(@term.author) : nil,
25+
"jobTitle": @term.author&.position
26+
}.compact,
2527
"publisher": {
2628
"@type": "Organization",
2729
"name": "Maybe",

0 commit comments

Comments
 (0)