Skip to content

Commit 992aaee

Browse files
authored
Merge pull request rails#53907 from p8/guides/fix-canonical
Fix canonical_url in guides
2 parents 591cc3d + 16dbac2 commit 992aaee

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

guides/rails_guides/generator.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ def generate_guide(guide, output_file)
193193
language: @language,
194194
direction: @direction,
195195
uuid: SecureRandom.uuid,
196-
digest_paths: @digest_paths,
197-
canonical_url: canonical_url(output_file)
196+
digest_paths: @digest_paths
198197
)
199198
view.extend(Helpers)
200199

@@ -225,12 +224,6 @@ def generate_guide(guide, output_file)
225224
end if !dry_run?
226225
end
227226

228-
def canonical_url(path)
229-
url = "https://guides.rubyonrails.org/"
230-
url += path unless path == "index.html"
231-
url
232-
end
233-
234227
def warn_about_broken_links(html)
235228
anchors = extract_anchors(html)
236229
check_fragment_identifiers(html, anchors)

guides/rails_guides/helpers.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def docs_for_menu(position = nil)
4747
end
4848
end
4949

50+
def canonical_url(path)
51+
url = "https://guides.rubyonrails.org/"
52+
url += path unless path == "index.html"
53+
url
54+
end
55+
5056
def code(&block)
5157
c = capture(&block)
5258
content_tag(:code, c)

guides/source/layout.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<link rel="apple-touch-icon" href="images/icon.png">
1515

16-
<link rel="canonical" href="<%= @canonical %>">
16+
<link rel="canonical" href="<%= canonical_url(@path) %>">
1717

1818
<script src="<%= digest_path('javascripts/@hotwired--turbo.js') %>" data-turbo-track="reload"></script>
1919
<script src="<%= digest_path('javascripts/clipboard.js') %>" data-turbo-track="reload"></script>

0 commit comments

Comments
 (0)