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

Add URL checks to Doctor #5760

Merged
merged 3 commits into from Jul 18, 2017
Merged

Add URL checks to Doctor #5760

merged 3 commits into from Jul 18, 2017

Conversation

pathawks
Copy link
Member

If a site does not provide an absolute URL in site.url, all sorts of wonky behavior can creep up, especially as sites rely more heavily on themes plugins that assume standard behavior.

To this end, I would like to add some simple URL checks to jekyll doctor to make sure that things are in good working order.

@@ -35,7 +37,8 @@ def healthy?(site)
fsnotify_buggy?(site),
!deprecated_relative_permalinks(site),
!conflicting_urls(site),
!urls_only_differ_by_case(site)
!urls_only_differ_by_case(site),
proper_site_url?(site)
Copy link
Member Author

Choose a reason for hiding this comment

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

If only Rubocop allowed Style/TrailingCommaInLiteral 😡

Copy link
Member

Choose a reason for hiding this comment

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

@pathawks what prevents us from adding Style/TrailingCommaInLiteral: { EnforcedStyleForMultiline: consistent_comma }to .rubocop.yml?

Copy link
Member Author

Choose a reason for hiding this comment

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

@DirtyF Laziness 😝

@pathawks
Copy link
Member Author

I should probably add a check for baseurl as well, as that is also the source of much frustration.

@pathawks
Copy link
Member Author

/cc: @jekyll/core @jekyll/ecosystem

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

LGTM! Not quite sure about the CI failures there, but 👍 on the content of the PR.

@pathawks
Copy link
Member Author

Fixes #5718

@pathawks
Copy link
Member Author

CI failures have been fixed 👍

Copy link
Member

@DirtyF DirtyF left a comment

Choose a reason for hiding this comment

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

So now you've got to set site.url? Before it was not mandatory and was automatically set in development mode or by GitHub Pages.

@pathawks
Copy link
Member Author

So now you've got to set site.url?

It's not mandatory, but since leaving it blank can cause problems with plugins or themes, users could at least be made aware of the situation.

Note that this only runs when a user runs jekyll doctor, not on every build. If a user is running jekyll doctor it's probably because something is not working as expected.

If a user is intentionally leaving site.url blank, they can safely disregard this warning.

@parkr
Copy link
Member

parkr commented Mar 31, 2017

If a user is intentionally leaving site.url blank, they can safely disregard this warning.

Hm, maybe just don't run the check then?

@parkr parkr added the pending-feedback We are waiting for more info. label Mar 31, 2017
@DirtyF
Copy link
Member

DirtyF commented Jun 21, 2017

@pathawks so should we break those tests: one that checks if site.url exists and warn if not, and another that checks that when site.url exists, it's valid?

url = site.config["url"]
[
url_exists?(url),
url_valid?(url),
Copy link
Member Author

Choose a reason for hiding this comment

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

@DirtyF So, replace these two lines with:

url_exists?(url) && url_valid?(url)

?

Copy link
Member

@DirtyF DirtyF Jun 21, 2017

Choose a reason for hiding this comment

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

I was thinking of moving url_exists? out of proper_site_url? in a separate single test to address Parker's concern, so we test first if site.url exists before launching proper_site_url. But as I suck at logic and programming, this is maybe a terrible idea :)

If what you are proposing does that, it's fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't follow.

We really want site.url to be set, either manually by the user or automatically by something like pages-gem. If site.url is blank, it is likely to cause problems and we should warn the user about this.

If a user has some special reason to use a blank site.url then they will understand that this warning does not apply to them.
On the other hand, if a user has simply neglected to set site.url and now things aren't working as expected, this check should alert them to the issue and suggest setting site.url. That is the entire point of this PR.

I'm probably not understanding your concerns; can you try to explain to me again now that I've explained my intent?

Copy link
Member

Choose a reason for hiding this comment

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

I get you perfectly and as it's impossible to tell if a blank site.url is intentional or not, you prefer to warn in both cases.

Maybe just make the messages more clear then?

bundle exec jekyll doctor
Warning: You didn't set an URL in the config file, you may encounter problems with some plugins.
bundle exec jekyll doctor
Warning: The site URL does not seem to be valid, check the value of `url` in your config file.
bundle exec jekyll doctor
Warning: Your site URL does not seem to be absolute, check the value of `url` in your config file.

@DirtyF
Copy link
Member

DirtyF commented Jun 22, 2017

@pathawks BTW what do you think about adding a "check your configuration" section with jekyll doctor in the docs? I just realized this command is not documented on the website 😕

@pathawks
Copy link
Member Author

@DirtyF Good idea. We should also add a request to the PR template that users post the output of jekyll doctor

@jekyllbot jekyllbot removed the pending-feedback We are waiting for more info. label Jun 22, 2017
@pathawks
Copy link
Member Author

For an example of what I hope to accomplish with this: jekyll/jekyll-sitemap#171

@pathawks
Copy link
Member Author

We should also add a request to the PR template that users post the output of jekyll doctor

Thank you @DirtyF for #6169

(Breadcrumbs 🥖)

@DirtyF
Copy link
Member

DirtyF commented Jul 18, 2017

@jekyllbot: merge +minor

Thanks @pathawks ❤️

@jekyllbot jekyllbot merged commit da65e94 into master Jul 18, 2017
@jekyllbot jekyllbot deleted the pr/url-doctor branch July 18, 2017 12:06
jekyllbot added a commit that referenced this pull request Jul 18, 2017
@jekyll jekyll locked and limited conversation to collaborators Jul 11, 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.

None yet

4 participants