Configure Eleventy not to use directories for output?

Viewed 442

Is it possible somehow to do a general configuration for Eleventy so that 'my_file.html' in the input folder ends up just as 'my_file.html' in the _site folder, not '/my_file/index.html'?

I know I can do it on a file by file basis with permalinks. But I'd like it configured for the site as a whole, if possible.

2 Answers

Unfortunately, since this behavior isn't encouraged, there isn't a simple configuration option to disable the directory output.

However, since permalink is part of the data cascade, you can set a global default, and in combination with the filePathStem computed data, you can set the output to be .html files.

To set a permalink using a global data file, add a permalink.js file to your global _data directory.

// _data/permalink.js
module.exports = '/{{ page.filePathStem }}.html'

There is also a config global data option coming soon to v1.0.0. I am not sure if it will handle the {{ page.filePathStep }} preprocessing, but if it does, that could be an option too, especially since it will keep config-related things inside the config file.

Related