Skip to content

Commit

Permalink
lib/Hakyll/Check.hs: support link-checking in *.xhtml files. (jasperv…
Browse files Browse the repository at this point in the history
…dj#969)

The Hakyll "check" command is used to validate links in your site's
output, but at the moment it only checks ".html" files. There is also
an "xhtml" extension associated with the application/xhtml+xml MIME
type that more or less contains HTML.

It's important for authors to use a different extension on xhtml+xml
files because browsers interpret them differently (they use a faster
but stricter parser). Thus simply renaming those files to "html" is
not recommended. Instead this commit teaches Hakyll to check "xhtml"
files as well.

A more thorough change would allow the user to specify what extensions
to consider as "html" -- for example, "htm" and "xhtm" are both
common. I however see little need for the complexity, since no one
else has hit the issue in so many years. This commit therefore makes
the smallest change possible and hard-codes "xhtml" as an additional
extension to be checked.

Notably, I have not added "index.xhtml" as a default document in
checkFileExists, because developing locally (file://) I'm forced to
avoid such things in the first place.
  • Loading branch information
orlitzky authored Apr 3, 2023
1 parent 3cf690f commit 201be22
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Hakyll/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ checkDestination = do
let htmls =
[ destinationDirectory config </> file
| file <- files
, takeExtension file == ".html"
, takeExtension file `elem` [".html", ".xhtml"]
]

forM_ htmls checkFile
Expand Down

0 comments on commit 201be22

Please sign in to comment.