Skip to content

Commit a97a4cc

Browse files
committed
Add canonical urls to articles and snippets
1 parent d1a69ec commit a97a4cc

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

app/content/layouts/article.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
twitter: {
1111
card: "summary"
12-
}
12+
},
13+
canonical: url_for(only_path: false, overwrite_params: nil)
1314
) %>
1415
<%= render "application/skip_to_content" %>
1516
<%= render_layout "application" do %>

app/views/share/snippets/show.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
},
88
twitter: {
99
card: @snippet.screenshot.attached? ? "summary_large_image" : "summary"
10-
}
10+
},
11+
canonical: share_snippet_url(@snippet)
1112
) %>
1213

1314
<%= render Pages::Header.new(title: "Share: Snippet") %>

config/initializers/meta_tags.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@
4646
# config.property_tags.push(
4747
# 'x-hearthstone:deck',
4848
# )
49+
50+
# John Mueller's suggestion is to avoid mixing canonical with noindex
51+
# https://github.com/kpumuk/meta-tags?tab=readme-ov-file#canonical-url
52+
config.skip_canonical_links_on_noindex = true
4953
end

0 commit comments

Comments
 (0)