11ty / eleventy Goto Github PK
View Code? Open in Web Editor NEWA simpler site generator. Transforms a directory of templates (of varying types) into HTML.
Home Page: https://www.11ty.dev/
License: MIT License
A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
Home Page: https://www.11ty.dev/
License: MIT License
I keep getting this error when trying to install the cli
personal ❯ sudo npm install -g eleventy-cli
Password:
npm WARN deprecated [email protected]: This package is deprecated. Use Array.isArray.
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b v2.5.7-h1 https://github.com/zachleat/ejs.git /Users/mighty/.npm/_cacache/tmp/git-clone-7b43542b
npm ERR! /Users/mighty/.npm/_cacache/tmp/git-clone-7b43542b/.git: Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mighty/.npm/_logs/2017-12-29T14_32_50_024Z-debug.log
Couple of ways to do layouts. You can use template engine specific stuff (blocks in nunjucks, for example) or eleventy provides a template agnostic way:
_includes/mylayout.njk
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{title}}</title>
</head>
<body>
{{_layoutContent | safe}}
</body>
</html>
template.njk
---
layout: mylayout
title: This will go into the title
---
Template Content
See this example:
Eleventy:TemplateWriter [ 'views/**/*.njk',
Eleventy:TemplateWriter 'views/**/*.md',
Eleventy:TemplateWriter '!./logs',
Eleventy:TemplateWriter '!./*.log',
Eleventy:TemplateWriter '!./npm-debug.log*',
Eleventy:TemplateWriter '!./node_modules/**',
Eleventy:TemplateWriter '!./.DS_Store',
Eleventy:TemplateWriter '!./_site/**',
Eleventy:TemplateWriter '!./content/*',
Eleventy:TemplateWriter '!./_site/**',
Eleventy:TemplateWriter '!./views/_includes/**',
Eleventy:TemplateWriter '!./views/_data/**' ] +0ms
Eleventy:TemplateWriter Found: +7ms
Eleventy:TemplateWriter [ 'views/_includes/base.njk',
Eleventy:TemplateWriter 'views/_includes/header.njk',
Eleventy:TemplateWriter 'views/postsarchive.md' ] +0ms
Input file: testing.md
---
title: My page title
renderData:
test1: My page titleparagraph
---
<title>{{ title }}</title>
<title>{{ renderData.test1 }}</title>
Outputs to
<title>My page title</title>
<title>
<p>My page titleparagraph</p>
</title>
Related #10
This is the error:
(node:99440) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: TemplateRender requires a tmplPath argument, instead of false
(node:99440) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Specifically talking about nunjucks filters here but others might be bad too. Doesn’t tell you what template failed, doesn’t tell you what filter failed. Super opaque error message that’s hard to track down.
https://github.com/11ty/eleventy#see-more-sample-projects
/blog/a-post/index.html
) with some static pages (e.g. /about/
) as well.I'm not sure you can do anything about this, but if I have some incorrect Pug syntax, I get an error like this:
File changed: index.pug
(node:17395) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Pug:4:17
2| html(lang="en")
3| head
> 4| title= Some Title
-----------------------^
5| body
6| h1= title
7| p Source available at
Syntax Error: Unexpected token
(node:17395) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Now, the "Error: Pug:4:17" and "Syntax Error: Unexpected token" is correct. The "confusing" part is the "UnhandledPromiseRejectionWarning" and the "DeprecationWarning".
This is the error I get if I use the pug command:
> pug . --output _site
~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:59
throw err;
^
Error: ./index.pug:7:17
5| html(lang="en")
6| head
> 7| title= Some Title
-----------------------^
8| body
9| h1= title
10| p Source available at
Syntax Error: Unexpected token
at makeError (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-error/index.js:32:13)
at Lexer.error (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:58:15)
at Lexer.assertExpression (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:86:12)
at Lexer.code (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:971:28)
at Lexer.callLexerFunction (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1319:23)
at Lexer.advance (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1352:15)
at Lexer.callLexerFunction (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1319:23)
at Lexer.getTokens (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1375:12)
at lex (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:12:42)
at Object.lex (~/.npm-packages/lib/node_modules/pug-cli/node_modules/pug/lib/index.js:99:27)
When running eleventy
with just one file (maybe more, I haven't tried) I always get "Wrote NaN files in xx seconds". The issue is with "NaN", not "xx" because I just put "xx" as a placeholder. ;)
To reproduce:
> git clone [email protected]:aakoch/eleventy-site.git
> cd eleventy-site/
> eleventy
Writing _site/index.html from ./index.pug
Wrote NaN files in 0.22 seconds
Travis CI is free for open source projects.
Reported in 11ty/eleventy-base-blog#5
I'm sure one could bolt something in after the fact, but it would be great to create an RSS feed from content so this can be used for a blogging platform without all of the bloat of something like Hugo or Jekyll.
Normalize urls inside of content.
Don’t require a directory as input, instead accept just a single file.
First off: 👏🏻 for this!
Coming from Jekyll etc. I expected underscored folders to be automagically ignored. Especially 'system' folders such as _includes
and _data
. I understand that you want to be more explicit with the .eleventyignore
but I can't get it to work...
My setup: input: ./src
, output: ./dist
with the following:
# .eleventyignore
# NOTE: these comments are for this issue and not in my .eleventyignore file...
# Try folder-name
_includes/
# Try specific file
_includes/layout-main.liquid
# Other folder name
_test
# Other specific file
README.md
.. results in (DEBUG):
> DEBUG=Eleventy* eleventy --input=src --output=dist --formats=liquid
Eleventy:Config Setting up global TemplateConfig. +0ms
Eleventy:TemplateWriter src/.eleventyignore ignoring: ./src/_includes +0ms
Eleventy:TemplateWriter src/.eleventyignore ignoring: ./src/_includes/layout-main.liquid +0ms
Eleventy:TemplateWriter src/.eleventyignore ignoring: ./src/_test +1ms
Eleventy:TemplateWriter src/.eleventyignore ignoring: ./src/README.md +0ms
Eleventy Directories:
Eleventy Input: src
Eleventy Data: src/_data
Eleventy Includes: src/_includes
Eleventy Output: dist
Eleventy Template Formats: liquid +0ms
Eleventy:TemplateWriter Searching for: +9ms
Eleventy:TemplateWriter [ 'src/**/*.liquid',
Eleventy:TemplateWriter '!./src/_includes/**',
Eleventy:TemplateWriter '!./src/_includes/layout-main.liquid',
Eleventy:TemplateWriter '!./src/_test/**',
Eleventy:TemplateWriter '!./src/README.md',
Eleventy:TemplateWriter '!./dist/**',
Eleventy:TemplateWriter '!./src/_includes/**',
Eleventy:TemplateWriter '!./src/_data/**' ] +0ms
Eleventy:TemplateWriter Found: +22ms
Eleventy:TemplateWriter [ 'src/_includes/layout-main.liquid',
Eleventy:TemplateWriter 'src/_includes/nav.liquid',
Eleventy:TemplateWriter 'src/_test/wat.liquid',
Eleventy:TemplateWriter 'src/dashboard.liquid',
Eleventy:TemplateWriter 'src/new.liquid' ] +0ms
Eleventy:TemplateWriter Template for src/_includes/layout-main.liquid added to map. +23ms
Eleventy:TemplateWriter Template for src/_includes/nav.liquid added to map. +2ms
Eleventy:TemplateWriter Template for src/_test/wat.liquid added to map. +1ms
Eleventy:TemplateWriter Template for src/dashboard.liquid added to map. +6ms
Eleventy:TemplateWriter Template for src/new.liquid added to map. +2ms
Eleventy:TemplateWriter Collection: collections.all has 5 items. +3ms
According to TemplateWriter.js:221 the files are correctly picked up and ignored for this.files
but are nonetheless included in this._getAllPaths()
The only file that gets correctly ignored is the README.md. And _data/
(which I've not exluded in my ignorefile). Somehow _includes/
is included.
So, for example, this.files
includes [.., '!./src/_test/**']
but this._getAllPaths() => globby(this.files)
results in [.., 'src/_test/wat.liquid']
.
Should globby not have excluded src/_test/wat.liquid
based on !./src/_test/**
?
Or am I missing something?
Some easy mechanism to test if current page matches some criteria (maybe just a string?)
https://twitter.com/ChrisFerdinandi/status/949012833647374336
We have pagination to iterate over data to create pages, but we also need a mechanism to group seemingly disparate pages (all blog posts in a directory, for example) and sort by certain criteria. Allow a similar API to pagination (next/prev/all links, page number, etc).
OSX 10.13.2
, node 8.9.1
, npm 5.5.1
npm install
getting the following:Enter passphrase for key '/Users/####/.ssh/id_rsa': ⸨░░░░░░░░░░░░░░░░░░⸩ ⠼ fetchMetadata: sill resolveWithNewModule [email protected] checking installablenpm WARN deprecated [email protected]: Please use https://github.com/pid/speakingurl instead
⸨░░░░░░░░░░░░░░░░░░⸩ ⠇ fetchMetadata: WARN deprecated [email protected]: Please use https://github.com/pid/speakingurl instead
Probably a problem on my end as I do not have admin rights to this machine and a proxy is in play.
npm install -g eleventy-cli
produces...
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://[email protected]/zachleat/ejs.git
npm ERR!
npm ERR! ssh: connect to host github.com port 22: Connection refused
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
Input file: testing.md
---
permalink: README.md
---
Testing
Outputs to ./<p>README.md</p>
# {{ pkg.name }}
{{ pkg.description }}
Extends runtime config by allowing other plugins to add to it.
const myPlugin = require("eleventy-plugin-myplugin");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(myPlugin);
};
I would be great if we could use Algolia for search.
The easy part is the user facing search interface, because it doesn't depend on eleventy.
The hard part is indexing. Here's an overview of indexing into Algolia.
Looks like the test failures relate to command line, path names, and CR-LF issues. This is Windows 10 with msysgit, perhaps results would be different with Bash on Ubuntu on Windows (WSL)? I'll try to dig into these but if anyone else has time please don't let me slow you down!
$ npm run test
> [email protected] test C:\wamp\www\eleventy
> ava
107 passed
7 failed
TemplateRenderTest » EJS Render Include
C:\wamp\www\eleventy\test\TemplateRenderTest.js:93
nder Include", async t => {
93: t.is(path.resolve(undefined, "/included"), "/included");
Rejected promise returned by test. Reason:
TypeError {
message: 'Path must be a string. Received undefined',
}
TemplateTest » More advanced getData()
C:\wamp\www\eleventy\test\TemplateTest.js:146
146: t.is(data[cfg.keys.package].name, "eleventy");
Difference:
- 'eleventy-cli'
+ 'eleventy'
TemplateTest » One Layout
C:\wamp\www\eleventy\test\TemplateTest.js:170
171: cleanHtml(await tmpl.renderLayout(tmpl, data)),
Difference:
`<div id="layout">␊
- <p>Hello.</p>␍␊
+ <p>Hello.</p>␊
</div>`
TemplateTest » Two Layouts
C:\wamp\www\eleventy\test\TemplateTest.js:201
202: cleanHtml(await tmpl.renderLayout(tmpl, data)),
Difference:
`<div id="layout-b">␊
<div id="layout-a">␊
- <p>value2-a</p>␍␊
- </div>␍␊
+ <p>value2-a</p>␊
+ </div>␊
</div>`
TemplateDataTest » getData()
C:\wamp\www\eleventy\test\TemplateDataTest.js:28
27: t.is(data.globalData.datakey1, "datavalue1", "simple data value");
variables, resolve pkg to its value.
Difference:
- 'eleventy-cli'
+ 'eleventy'
TemplateDataTest » addLocalData()
C:\wamp\www\eleventy\test\TemplateDataTest.js:51
50: t.is(data.globalData.datakey1, "datavalue1");
1: t.is(data.globalData.datakey2, "eleventy");
Difference:
- 'eleventy-cli'
+ 'eleventy'
TemplateDataTest » addLocalData() doesn’t exist but doesn’t fail
C:\wamp\www\eleventy\test\TemplateDataTest.js:70
t.is(withLocalData.globalData.datakey1, "datavalue1");
.is(withLocalData.globalData.datakey2, "eleventy");
71: t.deepEqual(Object.keys(withLocalData), beforeDataKeyCount);
Difference:
- 'eleventy-cli'
+ 'eleventy'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `ava`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
One of the big things that keeps me away from static site generators is the ability to schedule posts to go live at a future date/time.
I know it's a bit complicated, but I would a way to schedule posts in advance (even if it's just documentation on setting up the right continuous deployment script or something).
Add note about error messaging in lower versions.
I was looking at how to create site navigation for my Eleventy test project.
I do not think Pagination is appropriate for this so I looked at Collections:
Add the following to pages that should have a navigation entry:
---
title: My page
tag: nav
slug: "my-page"
---
..
.. which would allow a nav.liquid
partial to use collection.nav
and the use of post.slug
etc.
However, (as commented before) there is no easy way to get the 'current active page' and one would have to hardcode a href value (based on e.g. the slug).
This is why I've, for now, fallen back to almost hard-coding the entire navigation:
<ul role="navigation">
<li><a {% if slug == "myslug" %}aria-current="page"{% else %}href="/myslug/"{% endif %}>My Page</a></li>
<li><a {% if slug == "anotherslug" %}aria-current="page"{% else %}href="/anotherslug/"{% endif %}>Another Page</a></li>
</ul>
It would be great to have access to the implicit permalink
(or url
) for the current page.
Otherwise: what would be an Eleventy best-practice for creating site navigation?
Move to use the convention established in addLiquidTag
and addLiquidFilter
.
Hi :)
I just wanted to try your lib, I installed it & tryed it on a md file of mine but got this error :
Eleventy requires Node version 8 or above. You’re currently using 9.2.0.
After this not so frightening message I decided to remove this version check in \node_modules\eleventy-cli\cmd.js
and it finally worked well... what's the reason(s) to restrict the lib execution under node 8.x.x ?
See https://github.com/jprichardson/node-fs-extra/blob/HEAD/docs/remove.md
destroy
method on Template
Cheating methods that probably aren’t good enough:
# Dependency directories
node_modules/
Results in
Eleventy:TemplateWriter .gitignore ignoring: ./# Dependency directories +0ms
Eleventy:TemplateWriter .gitignore ignoring: ./node_modules +0ms
Requested by @DSchau and @mathiasbynens
Hi Zach,
Just trying to follow your Level 1 tutorial and getting some trouble with locale config.
Given my locale
is:
LANG="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_CTYPE="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_ALL=
When I run DEBUG=Eleventy* eleventy
Then I get the following error message
Eleventy:TemplateConfig Problem getting localConfig file, { Error: Cannot find module '/Users/frank/11y-giffleball/.eleventy.js' at Function.Module._resolveFilename (module.js:555:15) at Function.Module._load (module.js:482:25) at Module.require (module.js:604:17) at require (internal/module.js:11:18) at TemplateConfig.mergeConfig (/usr/local/lib/node_modules/@11ty/eleventy/src/TemplateConfig.js:44:21) at new TemplateConfig (/usr/local/lib/node_modules/@11ty/eleventy/src/TemplateConfig.js:23:24) at Object.<anonymous> (/usr/local/lib/node_modules/@11ty/eleventy/src/Config.js:5:18) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:573:32) code: 'MODULE_NOT_FOUND' } +1ms
And generated _site/index.html
does not interprete liquid syntax:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1></h1>
<ul>
</ul>
</body>
</html>
If you have a bunch of existing content that already is pointing to a specific layout, remap that to a completely different path in a single place in the config
.
> eleventy --version
0.1.5
Steps to reproduce:
Create the directoy ./src
, within it, create a index.html
file.
Run eleventy
. A file will be written to ./_site/src/index.html
. No errors.
Create .eleventy.js
as follows:
module.exports = {
dir: {
input: 'src'
}
};
Run elventy
.
Expected behavior:
eleventy
runs without failure.
Actual behavior:
The following error is shown. As far as I can tell, every eleventy
command produces that error.
(node:21055) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
at assertPath (path.js:28:11)
at Object.join (path.js:1244:7)
at Function.TemplatePath.normalize (/home/phil/.npm-global/lib/node_modules/eleventy-cli/src/TemplatePath.js:16:25)
at TemplateData.getGlobalDataGlob (/home/phil/.npm-global/lib/node_modules/eleventy-cli/src/TemplateData.js:48:23)
at <anonymous>
(node:21055) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21055) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
If .eleventy.js
config file does not exist, this argument will write a new config file with the current runtime arguments as config values. Will error if .eleventy.js
already exists.
For #41
Right now eleventy only ignores underscores on file names.
It would be great to be able to use Cloudinary for responsive images.
For content images inside Markdown (or other formats), it could use presets and a Liquid syntax as in the Jekyll-Cloudinary plugin.
It would be even better if it could use native Markdown syntax and some "filters" in templates.
I already use Cloudinary, so I can help define the features, maybe even provide some code… ;-)
I'm wondering how shortcodes might be handled. I really like how Hugo uses shortcodes (https://gohugo.io/content-management/shortcodes/) but they would be even better if they could be run through node scripts (Hugo is written in Golang and has no support for this currently).
Essentially, I'd expect to be able to write little snippets that take arguments, referencing a script that outputs markup and injects it back as part of the processed template. E.g.
{{shortcodeName arg1="foo" arg2="bar"}}
would run a script called shortcodeName.js
that takes "foo" and "bar" then exports/returns markup with those values processed somehow.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.