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 support for site.baseurl, workaround #618

Closed
wgmyers opened this issue Jan 10, 2021 · 3 comments · Fixed by #658
Closed

Add support for site.baseurl, workaround #618

wgmyers opened this issue Jan 10, 2021 · 3 comments · Fixed by #658

Comments

@wgmyers
Copy link

wgmyers commented Jan 10, 2021

When using html-proofer on a Jekyll site with non-empty baseurl such as /test, all internal links are reported as broken.

It would be great to be able to specify something like --internal_baseurl "BASEURL" on the command line, and then have the checker prepend the value of BASEURL to all internal links. This would also locate instances where BASEURL was incorrectly not prepended, and be extremely useful to Jekyll users.

Others have found a workaround with the url_swap option, but it does not allow replacing eg /test with the empty string or with /

$ htmlproofer --assume-extension --disable_external --url_swap "/test\:/" ./_site
htmlproofer 3.18.2 | Error:  undefined method `split' for /test\:/:Regexp

The workaround working for me is:

$ cd _site
$ ln -s . test
$ cd ..
$ htmlproofer --assume-extension --disable_external ./_site
@kylezervas
Copy link

ok thanks im going to try and farm this in to my on

@PeterJCLaw
Copy link
Contributor

Not sure if this has since been fixed, but I'm finding that this url swap works for this case: --url-swap "^/website/:/". That's to line up with a Jekyll setting of baseurl: /website.

I think the issue in the original example is possibly the use of \: rather than : to separate the original from the replacement?

The docs on this could definitely be clearer though -- I figured out my url swap by debugging the code.

@wgmyers
Copy link
Author

wgmyers commented Oct 18, 2021

@PeterJCLaw Thank you. You are quite right: I was using duff syntax, and the solution you give works for me also.

I have no idea what I thought I was doing with --url_swap "/test\:/" , but --url_swap "^/test/:/" is the answer.

PeterJCLaw added a commit to PeterJCLaw/html-proofer that referenced this issue Oct 18, 2021
PeterJCLaw added a commit to PeterJCLaw/html-proofer that referenced this issue Oct 18, 2021
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

Successfully merging a pull request may close this issue.

4 participants