Andy-set-studio / learneleventyfromscratch.com

In this Eleventy course, we go from a completely empty directory to a full-blown marketing site for a design agency, and along the way, we dive really deep into Eleventy and front-end development best practices.
https://learneleventyfromscratch.com/
120 stars 28 forks source link

Tag Extends not found #3

Closed wimmstr closed 2 years ago

wimmstr commented 2 years ago

Problem After Introducing Extend blocks I am getting errors thrown at me. Im a pretty raw beginner when it comes to this, so I dont even know if this is a right place to ask.

Errors I get after Npm start (Npx eleventy --serve):

Error writing templates: (more in DEBUG output) Having trouble writing template: dist/index.html

TemplateWriterWriteError was thrown Having trouble compiling template ./src/_includes/layouts/home.html

TemplateContentCompileError was thrown tag extends not found, file:./src/_includes/layouts/home.html, line:1

ParseError was thrown tag extends not found

Also getting Errors from

AssertionError was thrown: AssertionError: tag extends not found at assert regarding a bunch of variables in liquid.common.js, which seems odd to me.

Then it repeats starting with

Problem writing Eleventy templates: (more in DEBUG output)

Attempted Solutions

wimmstr commented 2 years ago

Found a solution. Dont know why it works. Run

"npx @11ty/eleventy --input=src --serve"

I have src definded as my input folder in .eleventy.... Oh frick. I forgot the n in .eleventy.js....

wimmstr commented 2 years ago

I found the original culprit. At least for me I cant put base.html inside layouts inside _includes. If i put base.html directly into _includes it works without errors.

See Warning in 11nty docs

wimmstr commented 2 years ago

Found the actual solution... base and home need to be .njk files instead of .html files,

Finally works now. Even in the layouts subfolder.

Andy-set-studio commented 2 years ago

Ah, I think this is actually your culprit:

in .eleventy.js, you need to set:

return {
  markdownTemplateEngine: 'njk',
  dataTemplateEngine: 'njk',
  htmlTemplateEngine: 'njk',
  dir: {
    input: 'src',
    output: 'dist'
  }
};

That allows html files to run through njk.

From: https://learneleventyfromscratch.com/lesson/3.html#getting-started-with-nunjucks

wimmstr commented 2 years ago

Thanks for the reply! This was not it though. I had eleventy configuered like this from the beginning.