diff --git a/app/views/articles/show.html.erb b/app/views/articles/show.html.erb
index 80d2a2a45..113558e49 100644
--- a/app/views/articles/show.html.erb
+++ b/app/views/articles/show.html.erb
@@ -36,13 +36,11 @@
<% end %>
<% end %>
-<% if !internal_navigation? %>
+<% if internal_navigation? %>
+ " />
+<% else %>
<%= content_for :page_meta do %>
- <% if @article.canonical_url.present? %>
-
- <% else %>
-
- <% end %>
+ " />
">
diff --git a/spec/requests/stories_show_spec.rb b/spec/requests/stories_show_spec.rb
index a4c2c65ca..08f847f3d 100644
--- a/spec/requests/stories_show_spec.rb
+++ b/spec/requests/stories_show_spec.rb
@@ -107,6 +107,18 @@ RSpec.describe "StoriesShow", type: :request do
get "/#{middle_username}/#{article.slug}"
expect(response.body).to redirect_to("/#{user.username}/#{article.slug}")
end
+
+ it "renders canonical url when exists" do
+ article = create(:article, with_canonical_url: true)
+ get article.path
+ expect(response.body).to include('"canonical" href="' + article.canonical_url.to_s + '"')
+ end
+
+ it "shodoes not render canonical url when not on article model" do
+ article = create(:article, with_canonical_url: false)
+ get article.path
+ expect(response.body).not_to include('"canonical" href="' + article.canonical_url.to_s + '"')
+ end
end
describe "GET /:username (org)" do