{
  "$type": "site.standard.document",
  "canonicalUrl": "https://www.simoncox.com/short-articles/2023-10-29-cleaning-up-the-11ty-config/",
  "description": "Learn how to organize your 11ty config file by creating separate plugin files. Improve maintainability and readability of your Eleventy project structure.",
  "path": "/short-articles/2023-10-29-cleaning-up-the-11ty-config/",
  "publishedAt": "2023-10-29T16:11:20.056Z",
  "site": "at://did:plc:tki7vwlanxbwrz2er67eaeqa/site.standard.publication/3mp4h4md7zv2y",
  "tags": "Eleventy",
  "textContent": "I read a couple of articles this week on cleaning up your 11ty config file, the initial one that I found from Robin Hoover and the second from Lene Saile in which Lene had added a 3rd method, adding another config file as a plugin which I then understood what I could do. Yes takes me a bit of time sometimes.\n\nI created a new folder named _11ty in my source folder and in that added new .js files for each of the plugins, functions, filters and collections I needed, and in each added the code for them. This included the module.exports section but with slightly changed code.\n\nplugin.js code example:\n\nThe module.exports line has changed from:\n\nto\n\n~\nmodule.exports = eleventyConfig => {\n\n\nWith all the plugin and filter code tucked into its own file for convenience and ease of maintenance my .eleventy.js file now looks like this:\n\n\nmodule.exports = function(eleventyConfig) {\n  // Plugins\n  eleventyConfig.addPlugin(require(\"./src/_11ty/cssmini.js\")); // CSS minification\n  eleventyConfig.addPlugin(require(\"./src/_11ty/rss.js\")); // RSS feed plugin\n  eleventyConfig.addPlugin(require(\"./src/_11ty/datetime.js\")); // Date Time plugin\n  eleventyConfig.addPlugin(require(\"./src/_11ty/collections.js\")); // Collections\n  eleventyConfig.addPlugin(require(\"./src/_11ty/image.js\")); // Image plugin\n  eleventyConfig.addPlugin(require(\"./src/_11ty/passthroughs.js\")); // passthroughs\n\n  return {\n    dir: {\n      input: \"src\",\n      output: \"public\"\n    }\n  }\n};\n~\n\nYou can see the paths to each plug in I have used.\n\nYes, this is more of a note to myself for the next time I need to do this but I hope it helps someone else too!",
  "title": "Cleaning up the 11ty config"
}