Hexo "Template render error" (EJS) in CI
Hexo renders theme layouts with EJS by default. When a layout reads a variable that is undefined for a page, or contains an EJS syntax error, generation throws "Template render error" naming the layout.
What this error means
hexo generate fails with "Template render error" and an EJS message such as "X is not defined" or "Could not find matching close tag", pointing at a theme layout.
FATAL Something's wrong. ...
Template render error: /themes/landscape/layout/post.ejs
ReferenceError: author is not definedCommon causes
A layout uses data missing for some pages
The EJS layout references page or config data that is absent for certain posts, throwing a ReferenceError during render.
An EJS syntax error in the theme
An unbalanced <% %> tag or stray delimiter in a layout makes EJS fail to compile.
How to fix it
Guard optional variables in the layout
Reference data defensively so a missing field does not throw.
<%- typeof author !== 'undefined' ? author : config.author %>Fix the EJS syntax the error names
- Open the layout file named in the error.
- Balance the EJS tags and correct the delimiter.
- Re-run
hexo generateto confirm it renders.
npx hexo generateHow to prevent it
- Default optional fields in theme layouts.
- Keep config values the theme expects populated.
- Generate locally before pushing to catch layout errors.