Prevent building a layout file in development server

A huge JSON is built from a layout template (store all blog posts).
How could I prevent this JSON beeing compiled when using the dev server ?

Thanks a lot

There are several ways, but it depends a little on how you have it set up, but:

  1. You can surround your “big template” (or the partial include) with {{ if not hugo.IsDevelopment }}{{ end }} (or {{ if not hugo.IsServer }}{{ end }})
  2. If your JSON file is backed by a content file, you could draft (or disable it with the build front matter config) in a cascade using the environment filter: Front matter | Hugo
1 Like

Thank you very much !
I feel stupid now. I read about IsServer and didn’t notice it was perfect for my JSON layout.


1 Like

There was a slight logical flaw in my original post, corrected now.

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