Add canonical and alternate link tags to all 'main' pages

This commit is contained in:
0x1eef 2024-05-15 00:59:40 -03:00
parent fe32825e2b
commit eeaf48bca8
7 changed files with 29 additions and 20 deletions

2
Rules
View file

@ -60,7 +60,7 @@ passthrough "/json/durations/*/*.json"
##
# require rules
require_rules "nanoc/rules/assets"
require_rules "nanoc/rules/redirect"
require_rules "nanoc/rules/redirect", {locales:}
require_rules "nanoc/rules/random", {locales:}
require_rules "nanoc/rules/stream", {locales:, tdata:, name_by_id:}
require_rules "nanoc/rules/index", {locales:, tdata:}

View file

@ -8,7 +8,7 @@
locales.each do |locale|
compile "/html/main/random.html.erb", rep: "random/#{locale}" do
context = Ryo.from({locale:})
filter(:erb, locals: {context:})
filter(:erb, locals: {locale:, locales:, context:})
filter(:tidy)
write("/#{locale}/random/index.html")
end

View file

@ -6,8 +6,8 @@
# to the surah index for a given locale (eg / -> /en/)
compile "/html/main/redirect.html.erb" do
filter(:erb, locals: {locales:})
filter(:tidy)
filter(:erb)
write("/index.html")
end

View file

@ -2,6 +2,16 @@
<html lang="<%= context.locale %>">
<head>
<title><%= t(context.locale, "TheNobleQuran") %></title>
<link
rel="canonical"
href="https://al-quran.reflectslight.io/<%= locale %>/random/"
/>
<% locales.each do |locale| %>
<link
rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/random/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>
</head>
<body>

View file

@ -2,9 +2,16 @@
<html lang="en">
<head>
<title><%= t("en", "TheNobleQuran") %></title>
<link rel="canonical" href="https://al-quran.reflectslight.io/en/">
<link rel="alternate" hreflang="ar" href="https://al-quran.reflectslight.io/ar/">
<link rel="alternate" hreflang="en" href="https://al-quran.reflectslight.io/en/">
<link
rel="canonical"
href="https://al-quran.reflectslight.io/en/"
/>
<% locales.each do |locale| %>
<link
rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>
</head>
<body>

View file

@ -8,16 +8,12 @@
<meta name="description" content="<%= t(locale, 'meta.index.description') %>">
<link
rel="canonical"
hreflang="<%= locale %>"
href="https://al-quran.reflectslight.io/<%= locale %>/"
/>
<% locales.each do |locale| %>
<link
rel="alternate"
type="text/html"
hreflang="<%= locale %>"
href="https://al-quran.reflectslight.io/<%= locale %>/"
/>
<link rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>
<%= opengraph(context) %>

View file

@ -8,16 +8,12 @@
<meta name="description" content='<%= t(locale, 'meta.stream.description', {surah_name: surah.name}) %>'>
<link
rel="canonical"
hreflang="<%= locale %>"
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah.slug %>/"
/>
<% locales.each do |locale| %>
<link
rel="alternate"
type="text/html"
hreflang="<%= locale %>"
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah.slug %>/"
/>
<link rel="alternate"
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah.slug %>/"
hreflang="<%= locale %>" />
<% end %>
<%= erb("_favicon.html.erb") %>
<%= opengraph(context) %>