How to generate a warning or error

I’m trying to find a way to throw an error or warning when hugo compiles markdown. There are a couple scenarios for this, but here’s an example:

+++
title = "This title is much too long for a page title and should be shortened to the recommended 50-60 characters according to SEO best practices"
+++

Here is my web page

Then in the theme partial, i would want to have a conditional which throws the warning or error in the console, halts the build, or modifies the web page so it shows a public warning…

if (title.length > 60){
throw.warning "Recommend reduce your title to 60 characters"
}

Have a look at errorf.

4 Likes

Thank you! I would hate to admit how long I spent hunting through the docs and Google; but errorf was exactly what I was looking for

2 Likes