Allow testing of sites published to subfolders #215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All our documentation for the Azure Service Operator project gets published into the subfolder
azure-service-operator
and we'd like to usehtmltest
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 filepathpost/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 tohttp://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.