diff --git a/app/helpers/seo_helper.rb b/app/helpers/seo_helper.rb
new file mode 100644
index 000000000..60330ada5
--- /dev/null
+++ b/app/helpers/seo_helper.rb
@@ -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
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 2c1f65349..6dcb21581 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -19,42 +19,12 @@
<% if CurrentUser.user.custom_style.present? && params.fetch(:css, "true").truthy? %>
<%= stylesheet_link_tag custom_style_users_path(md5: Digest::MD5.hexdigest(CurrentUser.user.custom_style)), media: "screen" %>
<% end %>
- <% if Danbooru.config.twitter_username.present? %>
-
- <% end %>
-
-
- <%= tag.meta name: "description", content: meta_description %>
+ <% if current_page?(root_url) %>
+ <%= json_ld_website_data %>
+ <% end %>
+
+ <%= tag.meta name: "description", content: meta_description %>
<%= tag.meta property: "og:type", content: "website" %>
<%= tag.meta property: "og:site_name", content: Danbooru.config.app_name %>
<%= tag.meta property: "og:title", content: page_title %>
diff --git a/app/views/posts/partials/index/_seo_meta_tags.html.erb b/app/views/posts/partials/index/_seo_meta_tags.html.erb
index 1c58f8d5a..cedb48987 100644
--- a/app/views/posts/partials/index/_seo_meta_tags.html.erb
+++ b/app/views/posts/partials/index/_seo_meta_tags.html.erb
@@ -1,6 +1,6 @@
<% if @post_set.query.is_empty_search? %>
<% page_title("#{Danbooru.config.app_name}: Anime Image Board", suffix: nil) %>
- <% meta_description("#{Danbooru.config.canonical_app_name} is the original anime image 'booru. Find over 3.75 million anime pictures categorized by over 100 million tags.") %>
+ <% meta_description site_description %>
<% atom_feed_tag "Posts", posts_url(format: :atom) %>
<% else %>
diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb
index f9570949c..439673809 100644
--- a/config/danbooru_default_config.rb
+++ b/config/danbooru_default_config.rb
@@ -355,6 +355,11 @@ module Danbooru
nil
end
+ def twitter_url
+ return nil unless Danbooru.config.twitter_username.present?
+ "https://twitter.com/#{Danbooru.config.twitter_username}"
+ end
+
# include essential tags in image urls (requires nginx/apache rewrites)
def enable_seo_post_urls
false
diff --git a/public/images/danbooru-logo-500x500.png b/public/images/danbooru-logo-500x500.png
new file mode 100644
index 000000000..5e652ad82
Binary files /dev/null and b/public/images/danbooru-logo-500x500.png differ