seo: update JSON-LD site metadata.
* Add the Danbooru logo and social media links to the Organization data. This is to make Danbooru eligible for Google's knowledge panel ([1], [2]). * Only include this metadata on the frontpage as per Google's recommendations ([3]). [1]: https://support.google.com/knowledgepanel/answer/9163198 [2], https://developers.google.com/search/docs/data-types/logo [3]: https://developers.google.com/search/docs/data-types/sitelinks-searchbox
This commit is contained in:
56
app/helpers/seo_helper.rb
Normal file
56
app/helpers/seo_helper.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
# https://yoast.com/structured-data-schema-ultimate-guide/
|
||||
# https://technicalseo.com/tools/schema-markup-generator/
|
||||
# https://developers.google.com/search/docs/data-types/sitelinks-searchbox
|
||||
# https://developers.google.com/search/docs/data-types/logo
|
||||
# https://search.google.com/structured-data/testing-tool/u/0/
|
||||
# https://search.google.com/test/rich-results
|
||||
# https://schema.org/Organization
|
||||
# https://schema.org/WebSite
|
||||
|
||||
module SeoHelper
|
||||
def site_description
|
||||
"#{Danbooru.config.canonical_app_name} is the original anime image booru. Search millions of anime pictures categorized by thousands of tags."
|
||||
end
|
||||
|
||||
def json_ld_website_data
|
||||
urls = [
|
||||
Danbooru.config.twitter_url,
|
||||
Danbooru.config.discord_server_url,
|
||||
Danbooru.config.source_code_url,
|
||||
"https://en.wikipedia.org/wiki/Danbooru"
|
||||
].compact
|
||||
|
||||
json_ld_tag({
|
||||
"@context": "https://schema.org",
|
||||
"@graph": [
|
||||
{
|
||||
"@type": "Organization",
|
||||
"@id": root_url(anchor: "organization", host: Danbooru.config.hostname),
|
||||
url: root_url(host: Danbooru.config.hostname),
|
||||
name: Danbooru.config.app_name,
|
||||
logo: "#{root_url(host: Danbooru.config.hostname)}images/danbooru-logo-500x500.png",
|
||||
sameAs: urls
|
||||
},
|
||||
{
|
||||
"@type": "WebSite",
|
||||
"@id": root_url(anchor: "website", host: Danbooru.config.hostname),
|
||||
"url": root_url(host: Danbooru.config.hostname),
|
||||
"name": Danbooru.config.app_name,
|
||||
"description": site_description,
|
||||
"publisher": {
|
||||
"@id": root_url(anchor: "organization", host: Danbooru.config.hostname),
|
||||
},
|
||||
"potentialAction": [{
|
||||
"@type": "SearchAction",
|
||||
"target": "#{posts_url(host: Danbooru.config.hostname)}?tags={search_term_string}",
|
||||
"query-input": "required name=search_term_string"
|
||||
}]
|
||||
}
|
||||
]
|
||||
})
|
||||
end
|
||||
|
||||
def json_ld_tag(data)
|
||||
tag.script(data.to_json.html_safe, type: "application/ld+json")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user