Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use canonical_url specified in page if present #211

Merged
merged 9 commits into from
May 25, 2017

Conversation

8parth
Copy link
Contributor

@8parth 8parth commented May 24, 2017

assign the canonical url to canonical_url specified by user in page otherwise use default generated url.

@@ -183,7 +183,11 @@ def page_lang

def canonical_url
@canonical_url ||= begin
filters.absolute_url(page["url"]).to_s.gsub(%r!/index\.html$!, "/")
if page["canonical_url"].present?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.present? only works in Rails. You'll want to use to_s.empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know that. Will update this with specified changes.

let(:page) { make_page( { "title" => "page title", "canonical_url" => "https://github.com/jekyll/jekyll-seo-tag/"} ) }
let(:canonical_url) { 'https://github.com/jekyll/jekyll-seo-tag/' }
it "uses specified canonical url" do
puts subject.canonical_url
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray puts.

Copy link
Contributor Author

@8parth 8parth May 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove puts, is this proper way to test or I need to create and use posts fixtures? I am not sure about this part 😅

@benbalter
Copy link
Collaborator

@8parth this is great, and thanks for working through our feedback. I made a few minor formatting changes, but think this should be good to merge. Thank you!

@benbalter benbalter merged commit 445339d into jekyll:master May 25, 2017
benbalter added a commit that referenced this pull request May 25, 2017
@jekyll jekyll locked and limited conversation to collaborators Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants