Html5validator CI?

I would like to continuously validate that my Hugo site is valid HTML5. I am thus thinking of setting up html5validator on Travis CI to automate the process. However, I have not seen mention of such a setup on this forum. Are there better or alternative tool(s) that people are using for this purpose?

In this case you will have a better chance finding information in a place that discusses CI processes. As Hugo is largely platform agnostic and outputs a directory, there isn’t much Hugo-specific to your question. :slight_smile:

1 Like

https://validator.w3.org/ for single pages

1 Like

That’s fair, but I am surprised (and perhaps disappointed) if I am the only one in the history of this forum to ask about best practices for validating Hugo’s HTML output using CI processes. This seems like something that ought to be commonplace among Hugo users.

Thanks, but I am looking for continuous integration.

HTML5 fully specifies how browsers deal with non-validating pages, so perhaps the act of validation is much less important than it used to be in the pre-HTML5 world, as validation no longer helps with cross-browser compatibility. If even the most serious users of Hugo are not validating the output without any issue, then perhaps the premise of my question is wrong. I am thinking of CI as an additional layer of sanity, but perhaps it is unnecessary.

I have not setup this myself but it should not be hard with a service like CircleCI.

See e.g.:

I got Travis working with html5validator, which is now reporting plenty of errors on my site. Here is the .travis.yml file:

language: python
python:
 - "3.6"
os: linux
addons:
  apt:
    packages:
      - openjdk-8-jre  # install Java8 as required by vnu.jar
install:
 - sudo snap install hugo --channel=extended
 - pip install html5validator
script:
 - hugo
 - html5validator --root public/ --also-check-css

I’ll have to evaluate whether these errors are actually worth fixing, but that is a separate question.

The errors it returned are actually helpful. html5validator works well and was quite simple to set up. I recommend it and will use it for future Hugo sites.

I can’t speak for others, but my templates are relatively simple and straightforward, and I build mostly documentation sites, so I test the output during template development and trust the filters and sanitation functions throughout hugo.

Sometimes I do spot checks where I’ll validate the entire site, but I don’t have errors or issues. For more complicated setups I might include it, but probably not on every build; I’d be concerned it adds substantial build time to your deployment. Maybe cache the results, only check differences, something like that. :slight_smile:

1 Like

Once I got this working, the next step I desired was to have CI also test for broken internal links. I found htmlproofer, a Ruby package that can both check for broken links and also validate HTML. It seems that there are indeed a few previous mentions of it in this forum. There is also htmltest, which has fewer features but is written in Go rather than Ruby.

1 Like

This is a great guide to getting htmlproofer working on Circle CI:

I use htmlproofer in my CircleCI builds and know of others that use htmltest in their deploys.

That we don’t post about it here simply means we got it up and running. So there’s nothing to discuss then. :slight_smile:

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.