Proper build configuration for Eleventy?

What’s the right Netlify build command to use for building a site that’s designed to use Eleventy?

After experimenting with Hylia and deciding I wanted to give Eleventy + Netlify a try, I created a new site from scratch that builds and loads just fine on my local development system using Eleventy at the command line.

I then created a github repo to use to deploy via Netlify, have associated that repo with my Netlify account so I can access it in my Netlify dashboard, but cannot figure out what build command to use to successfully build and deploy the site on Netlify.

I’ve discovered that other repos use netlify.toml to locally configure builds so have copied that and tried a variety of build command settings that have all failed. Netlify seems to never be able to find my build command, which I’ve tried as follows:

command = “eleventy”
command = “DEBUG=* eleventy”
command = “DEBUG=* npx eleventy”

Error messages in the log are of the form:
11:18:44 AM: Executing user command: DEBUG=* npx eleventy
11:18:46 AM: npx: installed 1 in 2.269s
11:18:46 AM: command not found: eleventy

What’s the right build command for Netlify to build my site using Eleventy??

My Netlify instance name is “admiring-wing-e1407e”

None of the common build configuration documentation even mentions Eleventy. I know I need to use Eleventy to turn my site source into a deployable site (via the _site publish folder) as that’s what I’ve been doing during development.

Thanks for helping a beginner get started with Netlify (and Eleventy).

David

For what it’s worth, here’s what I used for my netlify.toml file when I was using Eleventy by itself (rather than my current setup, which combines it with webpack):

# Netlify instructions for my site

[build]
  publish = "_site"
  command = "eleventy"

Don’t know if that tells you anything you didn’t already know. Might also check the Netlify GUI, just in case, although it’s supposed to be overridden by the netlify.toml file.

Thanks – much appreciated! That combination of build settings makes sense to me, so I’ve reset my netlify.toml file to use them. My builds still fail with the following error:

4:08:46 PM: Executing user command: eleventy
4:08:46 PM: /usr/local/bin/build: line 63: eleventy: command not found

So it seems like the problem isn’t my attempt to use eleventy per se, but somehow config related in that Netlify isn’t finding eleventy. (This does at least tell me that Netlify is using my netlify.toml file rather than the Netlify GUI.

I’m therefore now wondering if there’s something wrong with my package.json file…

Update. Somehow my package.json file didn’t list Eleventy itself as a dependency. I added it (as a dev-dependency) and this time the build succeeded and my site deployed to Netlify.

Will make sure and mention this in the blog post I’ll write about getting started with Eleventy and Netlify.

3 Likes

Glad you figured it out! :clap:

1 Like