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

Using htmlproof with Jekyll's baseurl #266

Closed
NathanHazout opened this issue Nov 10, 2015 · 4 comments
Closed

Using htmlproof with Jekyll's baseurl #266

NathanHazout opened this issue Nov 10, 2015 · 4 comments

Comments

@NathanHazout
Copy link

I am using Jekyll to build my site.

All my images, links, etc, use a variable called site.baseurl. eg:

<link href="{{site.baseurl}}/lib/bootstrap/css/bootstrap.css" rel="stylesheet">

When generated it looks like:

<link href="/MFPSamples/lib/bootstrap/css/bootstrap.css" rel="stylesheet">

When htmlproof runs on it, I get:

* internally linking to /MFPSamples/lib/bootstrap/css/bootstrap.css, which does not exist (line 18)

I tried to use href-swap but the new string value to give is not clear.
Using --href-swap \/MFPSamples\/: replaces with empty string, which means it translates to lib/bootstrap/css/bootstrap.css, which is a relative link, which is not always valid depending where you are.

Trying --href-swap \/MFPSamples\/:/ gives an error htmlproof 2.5.2 | Error: undefined methodsplit' for /MFPSamples/:/:Regexp`

@NathanHazout
Copy link
Author

OK I found part of the answer:
--href-swap \/MFPSamples: seems to work around the issue.

However it does not seem to apply it to scripts.

@afeld
Copy link
Contributor

afeld commented Dec 22, 2015

[hrep-swap] does not seem to apply it to scripts

See #219jekyll/jekyll#4122 (comment) was a good workaround in the meantime though.

@gjtorikian
Copy link
Owner

I can't make Proofer work with Jekyll's {{ site.baseurl }}, because I don't want to deal with parsing links and rewriting them to match the value in a specific _config.yml file. However, the change to get this working for scripts is completed for Proofer 3.0. When that's out, this should be fixed. Keep track of #219 for more info on that.

eguiraud added a commit to root-project/jekyll-action that referenced this issue Jun 18, 2020
This is to help HTML proofer not get tripped up by internal links
with baseurl, see gjtorikian/html-proofer#266
@Merovex
Copy link

Merovex commented Jul 20, 2020

Adding a comment if anyone is looking for this in 2020. I have run a blog for the better part of 9 years, and completely overlooked the use of {% site_url name-of-blog-post %}, which when included in a markdown article will yield the correct URL. As of Jekyll 4.0, use of post.url does not need the basename to properly render. So, by removing the baseurl and fixing my links, I was able to quiet 193 false-positive links in my blog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants