feat: add default meta tags for SEO

- Implement default_meta_tags method in ApplicationHelper
- Refactor application layout to utilize default_meta_tags

This change improves SEO by centralizing the meta tags configuration. It
ensures consistent metadata across the application while reducing
repetition in the layout files.
This commit is contained in:
songtianlun 2025-04-08 16:48:22 +08:00
parent 41150ba78b
commit a156cc04d1
2 changed files with 24 additions and 16 deletions

View File

@ -25,4 +25,27 @@ module ApplicationHelper
def current_user_is_admin?
current_user&.admin?
end
def default_meta_tags
{
site: "TodayAIWeather",
title: "TodayAIWeather",
description: "Experience weather through artistic AI visualization. Daily updated weather art for cities worldwide.",
keywords: "AI weather art, weather visualization, city weather, artificial intelligence",
separator: "—".html_safe,
reverse: true,
og: {
site_name: "TodayAIWeather",
type: "website",
keywords: "ai, ai web, ai art, ai weather, weather art, AI visualization, today ai weather",
url: request.original_url
},
alternate: {
"en" => url_for(locale: "en"),
"zh-CN" => url_for(locale: "zh-CN"),
"ja" => url_for(locale: "ja"),
"ko" => url_for(locale: "ko")
}
}
end
end

View File

@ -5,22 +5,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<%= display_meta_tags(
site: 'TodayAIWeather',
reverse: true,
og: {
site_name: 'TodayAIWeather',
type: 'website',
keywords: "ai, ai web, ai art, ai weather, weather art, AI visualization, today ai weather",
url: request.original_url
},
alternate: {
"en" => url_for(locale: 'en'),
"zh-CN" => url_for(locale: 'zh-CN'),
"ja" => url_for(locale: 'ja'),
"ko" => url_for(locale: 'ko')
}
) %>
<%= display_meta_tags(default_meta_tags) %>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>