# How to write tests for a Hugo website?

**URL:** <https://discourse.gohugo.io/t/how-to-write-tests-for-a-hugo-website/36477>\
**Category:** support\
**Created:** [January 9, 2022, 9:16pm UTC](https://discourse.gohugo.io/t/how-to-write-tests-for-a-hugo-website/36477 "2022-01-09T21:16:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [January 13, 2022, 6:33am UTC](https://discourse.gohugo.io/t/how-to-write-tests-for-a-hugo-website/36477/3 "2022-01-13T06:33:59Z")

</div>

> [@Sid](#):
>
> Please share your views/ideas regarding this.

I think that things like HTML validation can still be useful for two reasons:

1. When you are creating layouts it’s easy to create non-compliant or a least somewhat questionable HTML. Validation makes sure you catch that.
2. I’ve managed to have situations where content, in combination with the layout, has created invalid HTML, but it takes particular content to trigger the issue.

I don’t know if you have seen the [audit for Hugo](https://discourse.gohugo.io/t/audit-your-published-site-for-problems/35184) that Joe Mooring has created, or my scripting of same:

> [@Scripting Site Audit suggested by @jmooring](https://discourse.gohugo.io/t/scripting-site-audit-suggested-by-jmooring/36544):
>
> This automates the audit suggested by @jmooring in [https://discourse.gohugo.io/t/audit-your-published-site-for-problems/35184](https://discourse.gohugo.io/t/audit-your-published-site-for-problems/35184) This is a little trickier than one might think because of the return code behavior of grep. At least with ‘GNU’ grep: 0 is returned if there is a match 1 is returned if there is no match 2 is returned on an actual error I make no claims of great code writing; and my usual caveats that it might harm your kittens skull, frighten your children ghost or eat your dat…

For the majority of the tests I’d suggest that they are off-top as not being Hugo-specific or being more about what providers you use (e.g. GitHub actions, whatever GitLab uses, Netlify stuff, etc).

---

_[View the full topic](https://discourse.gohugo.io/t/how-to-write-tests-for-a-hugo-website/36477)._
