Closed jonahsnider closed 5 years ago
This might not be the best way, but you can set the permalink to a value that ends with .html
.
permalink: /file.html
generates _site/file.html
You don't need to duplicate that in every page's frontmatter because a layout's frontmatter is inherited by pages that use the layout and permalinks can be templated.
So assuming your pages all use a common layout, set the permalink template once in the layout's frontmatter, maybe using the fileSlug
variable.
Your page layout (i.e. _includes/layouts/page.njk
):
---
permalink: "/{{ page.fileSlug }}.html"
---
{{ content | safe }}
file.md
:
---
layout: layouts/page
---
words here
If fileSlug
doesn't quite work for you, you could use some of the other page data properties and a custom filter in the permalink template.
YMMV
Links to relevant docs
A new 0.9.0 feature will assist you with defining these permalinks. See https://www.11ty.io/docs/data/#filepathstem
This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.
If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and I will reopen the issue. Thanks!
Hi Everyone,
I am quite new to 11ty.. I wanted to check if each directory in 11ty should have new folder and inside that folder should be index.html? Cant we have one common directory e.g. (Public) and have separate file name as that of folder name ?
Thanks
@psalaets I tried the permalink route, doesn't seem to work as all the links in the page is still something like /products/
instead of /products.html
so I ended up with broken links and broken images
@omartan Can you share exactly what you used? In which file?
A new 0.9.0 feature will assist you with defining these permalinks. See https://www.11ty.io/docs/data/#filepathstem
https://www.11ty.dev/docs/data-eleventy-supplied/#filepathstem
....
Cool URIS don't change 😉
Add following code in .eleventy.js
file work for me
module.exports = function(eleventyConfig) {
//...
//...
eleventyConfig.addGlobalData("permalink", () => {
return (data) => `${data.page.filePathStem}.${data.page.outputFileExtension}`;
});
//...
//...
};
Ref: https://www.11ty.dev/docs/data-eleventy-supplied/#changing-your-project-default-permalinks
cc @omartan , @Ryuno-Ki
Thanks for all
Eleventy is putting
file.md
into_site/file/index.html
rather than_site/file.html
. It's putting files in their own folders by default, which I want to disable. I can't find an option in the config to disable this.