Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip date from directory slugs when calculating page.fileSlug #2111

Merged

Conversation

AleksandrHovhannisyan
Copy link
Contributor

@AleksandrHovhannisyan AleksandrHovhannisyan commented Nov 20, 2021

Closes #1947

2021-11-20-my-awesome-post/index.md gets a slug of my-awesome-post rather than 2021-11-20-my-awesome-post.

@AleksandrHovhannisyan AleksandrHovhannisyan force-pushed the directory-slug-strip-out-date branch from 66f517e to 2488ab1 Compare November 20, 2021 13:38
@zachleat zachleat added the breaking-change This will have to be included with a major version as it breaks backwards compatibility. label Feb 18, 2022
@zachleat zachleat added this to the Eleventy 2.0.0 milestone Feb 18, 2022
@zachleat
Copy link
Member

Agree with this one but (as you said in #1947) it is a breaking change, so it will need to wait until 2.0—sorry!

@Brixy
Copy link

Brixy commented Mar 10, 2022

This would be great for a 2.0 release.

Sorry to barge in like this, but wouldn’t this (only) make sense if images and other assets were supported in the content folders—particularly for people coming from other SSGs like Hugo or Jekyll.

src/posts/
         /(2022-03-10-)some-title/
                    /index.html
                    /cover.png
                    /image.jpg
         /(2022-03-10-)good-title/
                    /index.html
                    /cover.png

This would resolve #1140 and many other issues, I guess.

Thanks, guys!

@AleksandrHovhannisyan
Copy link
Contributor Author

@zachleat Is there anything I can do to reduce the impact of merging this PR? Would it be better if we added a new flag to 11ty to opt into this behavior? If so, any pointers on where I should look for that and how to mock it in tests?

@zachleat zachleat merged commit bf79be5 into 11ty:master May 10, 2022
@zachleat
Copy link
Member

Merging this one! It’ll ship with 2.0.0-canary.10. Thank you @AleksandrHovhannisyan!

@zachleat zachleat removed the on-hold label May 10, 2022
zachleat added a commit that referenced this pull request May 10, 2022
@AleksandrHovhannisyan AleksandrHovhannisyan deleted the directory-slug-strip-out-date branch May 10, 2022 17:10
@zachleat zachleat changed the title Strip date from directory slugs Strip date from directory slugs when calculating page.fileSlug Jan 10, 2023
@zachleat
Copy link
Member

For future visitors curious about page.fileSlug, docs are here: https://www.11ty.dev/docs/data-eleventy-supplied/#page-variable

zachleat added a commit to 11ty/11ty-website that referenced this pull request Jan 17, 2023
@mahnunchik
Copy link

It would be helpful to strip date from filename if it is separated from title by space too.

myDir/2018-01-01 index.md => myDir
2018-01-01 myDir/index.md => myDir

@nycki93
Copy link

nycki93 commented Sep 13, 2024

Can I disable this? I actually want the slugs to match my filenames and not do anything I didn't ask for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

page.fileSlug and directory index files: date doesn't get stripped out
5 participants