Skip to content

Commit

Permalink
Merge pull request #2543 from ghoppe/fix-canonical-link
Browse files Browse the repository at this point in the history
Use correct attribute (href) in canonical link. Full path preferred.
  • Loading branch information
parndt committed Feb 18, 2014
2 parents 28bc715 + fbcadb9 commit 25b98bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app/views/refinery/_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
<title><%= browser_title(yield(:title)) %></title>
<%= raw %(<meta name="description" content="#{@meta.meta_description}" />) if @meta.meta_description.present? -%>
<%= raw %(<link rel="canonical" content="#{@canonical}" />) if @canonical.present? -%>
<%= raw %(<link rel="canonical" href="#{request.protocol}#{request.host_with_port}#{@canonical}" />) if @canonical.present? -%>
<%= csrf_meta_tags if Refinery::Core.authenticity_token_on_frontend -%>
<%= yield :meta %>
Expand Down
8 changes: 8 additions & 0 deletions pages/spec/features/refinery/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ def standard_page_menu_items_exist?
before do
Page.stub(:fast_menu).and_return([page_cs])
end

describe 'canonical url' do
it 'should have a canonical url' do
visit '/about-us'

page.should have_selector('head link[rel="canonical"][href^="http://www.example.com/about-us"]', visible: false)
end
end

describe 'not set' do
it 'makes friendly_id from title' do
Expand Down

0 comments on commit 25b98bc

Please sign in to comment.