Nunjucks permalink won't write to "_redirects" file

So, I have followed the JAMstack tutorial video:

At about 2:20:20 into the video, the topic of redirects has been introduced, the “src/redirects.njk” (see below) file has been written, and the file is saved, triggering a site build. A file named “dist/_redirects” is output in the video and thus is what I expect. However, my build will ONLY create a file, “dist/redirects/index.html”, which apart from the wrong location and file name, has the correct syntax.

I have copied everything else precisely in this video yet getting different output file location and name. The eleventy / nunjucks documentation has proven unhelpful, to say the least. How do I get nunjucks to output a file where I want it, with an underscore prefix, not in a sub directory with an index.html, not with any extension? I would rather hope a script to manually rename a file is unnecessary.


permalink: _redirects

{%- for item in news %}
/ /{{ }}/index.html 200 Country={{ }}
{%- endfor %}



Wow, this one is a bit strange. It looks like a recent change to Eleventy, in all honesty, based on this issue in the repo. Therefore, it’s going to need some jiggery-pokery to get it working. I think you’ll need to check out the Computed Data feature.

Thank you for the hint. The bug report may be related somehow, but is not at all clear. The eleventy documentation is unhelpful, to say the least. At the top of the permalink doc page, the W3C convention of “Cool URLs don’t change” is referenced. It very clearly declares that file name extensions should be omitted from a site. (I realize this might traditionally be done via redirects). Yet the tool goes right on ahead and defaults to .html file output, with seemingly no obvious way to remove the file name extension on a per-file basis, maybe globally, probably not even then. I should not have this much difficulty to achieve a simple task. I should not have to go searching through a tool’s bug archive and each line of code to find undocumented features and bugs. At that point, with the time wasted, I could have written a more intelligently designed templating engine. If I have to use my own scripts to quickly and easily do tasks that this fancy tool is supposed to do for me, then the tool is broken and worthless and coded by morons. Might as well just write my own templating engine and do this right, rather than try to fight an uphill battle on a brownfield project with horrible design decisions and piss poor documentation. Netlify is a great service. I am disappointed that my introduction used such horrible tooling as an example, with breaking changes barely even 2 months from video release.

I’m sorry that you’re having a torrid time, @warp9pnt9. I totally sympathise! On the plus side, SSGs are coming along leaps and bounds. There’s lots out there, each with their own flagship features and points-of-note.

As for links without extensions – you can in fact enable this from within the Netlify UI. There’s a discussion here and our docs for reference too :slight_smile:

It looks like your source code got “ate” a bit by the forum, can you repost your code? You can absolutely have a completely different file name for your permalinks in Eleventy. It’s how I convert something.liquid to somethingelse.json.