Allow CLI --output=output.html to override permalink of --input=input.html
#3995
Replies: 6 comments
-
|
Actually, rereading your original comment of "I want to compile the test.njk file I have in the root directory to test.html in the same directory.", I think that pitfall does potentially apply (assuming Eleventy tries to parse the generated HTML files on subsequent builds). Or if you're strictly using Eleventy to build single templates and output to the same input directory (in which case the caveat might NOT apply). My frontmatter comment might still stand. I guess it depends on how you're building. If you want to throw your project up in a public GitHub repo I can take a look and see if we can get it building how you want it. I'm a bit curious about the HTML partials above for "head.html", "header.html", "footer.html", and "scripts.html".
|
Beta Was this translation helpful? Give feedback.
-
|
Gotcha. I'm processing no other files in the entire project, so I was hoping to not have to add front matter or any other 11ty-specific configuration to the project to process the one file. A use case to consider, perhaps, but good to know that the behavior I ran into is expected 🥲 |
Beta Was this translation helpful? Give feedback.
-
|
Ah, updated my comment above. Also interesting point from your output above: eleventy --dryrun --input=test.njk --output=test.html
[11ty] Skipping test.html/test/index.html from ./test.njkSo another gotcha is the --input flag
Whereas the --output flag
Which you can see from your output above: "test.html/test/index.html" I'm still struggling to come up with a workaround that isn't |
Beta Was this translation helpful? Give feedback.
-
|
Ahh good note about the documented difference in how the input and output flags work. Thank you for that.
Noted! But doesn't this suggest that |
Beta Was this translation helpful? Give feedback.
-
Ah ha! Except it is writing to the top level directory! It's writing the output to "test/index.html" in the top-level directory (which is the same level as your .eleventy.js config file, or the ./test.njk file). I have this working locally: ---
permalink: test.html
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
</head>
<body>
{% include "content.html" %}
</body>
</html>Where my package.json "build" script looks like eleventy --input=test.njk --output=.. For example, here's my package.json "scripts": {
"build": "eleventy --input=test.njk --output=.",
"postbuild": "mv test/index.html test.html",
"test": "echo \"Error: no test specified\" && exit 1"
},Now when I run npm run build it will run the I guess a final option might be seeing if you can use npx nunjucks-cli "*.njk" -p ""Not sure why I had to use that weird npx nunjucks-cli "*.njk"
node:internal/validators:120
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:371:5)
at validateString (node:internal/validators:120:11)
at resolve (node:path:1098:7)
at Object.<anonymous> (/private/tmp/11ty-2184/node_modules/nunjucks-cli/main.js:55:18)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v17.3.1I'll file a bug in https://github.com/jeremyben/nunjucks-cli, but not sure how active that repo is. 🤷 |
Beta Was this translation helpful? Give feedback.
-
|
Ah, this is the first time I’ve seen a request to override the permalink of
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I'm using Eleventy on the command line to compile a Nunjucks file into an HTML file. It works great but I'm having trouble getting the output to go where I want to. I want to compile the
test.njkfile I have in the root directory totest.htmlin the same directory. I've read the using the same input and output directory pitfall page, but I don't think it applies here.To Reproduce
Contents of
test.njkbelow, all of the included files are simple HTML files:Trying to compile:
Expected behavior
I want
test.htmloutput to the root directory, not under atestortest.htmlfolder.Interestingly, it worked back when I had the file named
index.html.Environment:
Beta Was this translation helpful? Give feedback.
All reactions