add additional meta tags for seo
This commit is contained in:
49
app/views/posts/partials/index/_seo_meta_tags.html.erb
Normal file
49
app/views/posts/partials/index/_seo_meta_tags.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<% if @post_set.has_wiki? %>
|
||||
<% strip_dtext(@post_set.wiki_page.presenter.excerpt).tap do |title| %>
|
||||
<%= tag.meta name: "og:title", content: title %>
|
||||
<%= tag.meta name: "twitter:title", content: title %>
|
||||
<% end %>
|
||||
<% elsif @post_set.tag_string.present? %>
|
||||
<% "#{@post_set.humanized_tag_string} - #{Danbooru.config.app_name}".tap do |title| %>
|
||||
<%= tag.meta name: "og:title", content: title %>
|
||||
<%= tag.meta name: "twitter:title", content: title %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% Danbooru.config.description.tap do |title| %>
|
||||
<%= tag.meta name: "og:title", content: title %>
|
||||
<%= tag.meta name: "twitter:title", content: title %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @post_set.hide_from_crawler? %>
|
||||
<meta name="robots" content="nofollow,noindex">
|
||||
<% end %>
|
||||
|
||||
<% if @post_set.has_explicit? %>
|
||||
<meta name="rating" content="adult">
|
||||
<% end %>
|
||||
|
||||
<%= tag.meta name: "canonical", content: posts_url(tags: params[:tags], host: Danbooru.config.domain) %>
|
||||
|
||||
<% if params[:tags].present? %>
|
||||
<% "Find the best art of #{params[:tags].tr('_', ' ').titleize} on #{Danbooru.config.app_name}".tap do |desc| %>
|
||||
<%= tag.meta name: "description", content: desc %>
|
||||
<%= tag.meta name: "og:description", content: desc %>
|
||||
<%= tag.meta name: "twitter:description", content: desc %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% Danbooru.config.description.tap do |desc| %>
|
||||
<%= tag.meta name: "description", content: desc %>
|
||||
<%= tag.meta name: "og:description", content: desc %>
|
||||
<%= tag.meta name: "twitter:description", content: desc %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= tag.meta name: "og:type", content: "website" %>
|
||||
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
|
||||
|
||||
<% if @post_set.best_post.present? %>
|
||||
<%= tag.meta name: "twitter:image", content: @post_set.best_post.file_url %>
|
||||
<%= tag.meta name: "og:image", content: @post_set.best_post.file_url %>
|
||||
<%= tag.meta name: "twitter:card", content: "summary_large_image" %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user