Many websites today are built using static site builders and markdown with embed data: the JAM Stack. Markdown alone is useful for writing content. Adding Frontmatter YAML headers to Markdown allows us to embed meta data for static site builders. To validate this content to SEO we will share a test.
Say you have a website built with Hugo. You might want to read all the content and check that the title and description properties of the markdown are of an appropriate length. We can do so using Jest and Node JS.
We need a few node dependencies for this examples:
Test with Jest
Let's write a test that loads all the Markdown files in the
folder and parses their markdown frontmatter. We then return a result for various tests such as description length. We use Jest to run the tests:
to run the test.