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

Allow testing of sites published to subfolders #215

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

theunrepentantgeek
Copy link

@theunrepentantgeek theunrepentantgeek commented May 23, 2023

All our documentation for the Azure Service Operator project gets published into the subfolder azure-service-operator and we'd like to use htmltest to catch our broken links.

This PR adds support for this scenario, allowing verification of websites that aren't published to the root of a server.

New configuration BaseURL allows specifying the final URL to which the site will be published.

Any trailing folder that is a part of this URL will be trimmed from absolute URLs before checking to see if the file exists. For example, given BaseURL: http://www.example.com/blog, an absolute reference to /blog/post/2023-05-24.html will have /blog/ trimmed from the start, leaving the filepath post/2023-05-24.html for testing.

New configuration CheckSelfReferencesAsInternal (default: false) allows checking of self-external references as though they are internal.

If you have BaseURL: http://www.example.com/blog and a reference to http://www.example.com/blog/post/2023-05-24.html, instead of failing as a broken link (since the file hasn't yet been published), it will now be converted into the internal reference /blog/post/2023-05-24.html and checked.

Full tests are included.

Closes #45
Closes #47
Closes #184

Some background: We've previously been using different tools to try and verify our markdown prior to rendering by Hugo, but we've had multiple issues with broken links making it through to our live website.

@wjdp
Copy link
Owner

wjdp commented May 31, 2023

@theunrepentantgeek Nice, thanks for the PR. Will take a look at this

@arusahni
Copy link

Hi @wjdp! I hate comment-bumping, but I was wondering if you had a chance to take a look at this PR. I just encountered a need for this.

@theunrepentantgeek
Copy link
Author

@wjdp Is there anything I can do (as the PR author) to make this easier for you to review and merge?

And while I'm here - many thanks for htmltest.
I know that often it's a thankless job doing the hard work maintaining an open source tool, and that it can be difficult to find the time it deserves. So, once again, thanks.

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