me in ur replies
-
Jason Shellenreplied to Zach Leatherman :11ty: on last edited by
@zachleat Hah! Eleventy is good, congratulations on v3!
I don't know if this is the place to ask but I'm having issues migrating a bunch of old md files like YYYY-MM-DD-title-of-post.md to be at a path like domain.com/title-of-post is there a way to do this in Eleventy? Seems like I would need to strip dates out of the actual filename to make this work. Am I missing an easy setting somewhere? Thanks in advance.
-
@shellen @zachleat One thought would be to use js front matter for those files in a directory data file and use a regex to set the permalink based on the filename, but removing the up-front date part. You might consider asking this in the #11ty Discord. There's a lot of great help there. https://www.11ty.dev/blog/discord/
-
Zach Leatherman :11ty:replied to Jason Shellen on last edited by
@shellen sorry for the late reply but this behavior is enabled by default in Eleventy!
> If a date key is omitted from the file, we then look for a YYYY-MM-DD format anywhere in the file path (even folders).
-
Jason Shellenreplied to Zach Leatherman :11ty: last edited by
@zachleat Thanks for the pointer and trying to wrap my head around this so bear with me.
What I want: example.com/this-is-a-post-title
What I'm getting: example.com/2018-10-22-this-is-a-post-title
I have dates in frontmatter and in the filename. Can I say "don't use dates in path at all"?
-
Zach Leatherman :11ty:replied to Jason Shellen last edited by
@shellen ah, my apologies—I got my wires crossed a little bit. The date in your file path can inform the `page.date` for the page but won’t (by default) influence the permalink output location.
You can use `page.filePathStem` to do this, though (and the file path date will be stripped out).
Consider this config, modified from https://www.11ty.dev/docs/permalinks/#remove-trailing-slashes
eleventyConfig.addGlobalData("permalink", () => {
return (data) => `${data.page.filePathStem}/`;
})Thus, 2001-01-01-test.md -> test/index.html