Enhancement: Smart renaming of files #432

Closed
opened 2026-10-05 02:47:03 +02:00 by adam · 6 comments
Owner

Is your feature request related to a problem? Please describe.
Yes. See two common issues with posting

Dates in filenames

When you create a new piece of content, FM requests the title, so you could type something like my new post and then FM creates a file for you, naming it yyyy-MM-dd-my-new-post.md. But I frequently put up future posts that should not be seen for days or even weeks in the future. While I can change the date in the YAML front matter, the filename does not change, making it hard to maintain the files.

Titles in a post

When you create a new piece of content, you type a title and FM creates the file for you. However:

  1. After you create the file FM provides a UI telling you if the title may be too long
  2. After you type the title, you may decide to change it completely. For example, I did this just recently:
    Original title: Digital transformation and the dance between agilty and structure in Government
    Udpated title: Agile Development for Digital Government Services: Challenges and Success Factors
    Updated title (once again): Digital transformation and agility in government
  3. You then have to copy the new title, go to Explorer, locate the file and rename it manually

Problem statement

  • Your filename's date prefix may not match the isPublishDate for the post
  • Your filename's title may not match the title in the post
  • Users will have difficulty managing their content since the filename ultimately represents the date and title of the content. For example, sorting content will be more difficult

Value statement

  • Content creators often write future posts, so this will support a common use case scenario
  • Content creators often change the dates and titles of their posts, so that will support a common use case scenario

Describe the solution you'd like
Ideally, there is a "Smart rename" option in FM that allows me to rename the file with the updated datetime that is designated as isPublishDate and also modify the title of the filename if that changed (I do not believe there is a isTitle boolean, but I assume FM always expects a title?).

Optionally, offer a UI to modify the file name manually, but follow all the business rules you use to create a filename. For example, if I rename a file and type:

2023 10 03 Welcome to October!

The filename will be:
2023-10-03-welcome-to-october.md

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
The following image represents a common use case, where I create a post where FM assumes I am going to post on the creation date. FM assumes the filename remains the same despite changing the date and title in YAML.

file-naming-issue
**Is your feature request related to a problem? Please describe.** Yes. See two common issues with posting ## Dates in filenames When you create a new piece of content, FM requests the title, so you could type something like `my new post` and then FM creates a file for you, naming it `yyyy-MM-dd-my-new-post.md`. But I frequently put up future posts that should not be seen for days or even weeks in the future. While I can change the date in the YAML front matter, the filename does not change, making it hard to maintain the files. ## Titles in a post When you create a new piece of content, you type a title and FM creates the file for you. However: 1. After you create the file FM provides a UI telling you if the title may be too long 2. After you type the title, you may decide to change it completely. For example, I did this just recently: Original title: Digital transformation and the dance between agilty and structure in Government Udpated title: Agile Development for Digital Government Services: Challenges and Success Factors Updated title (once again): Digital transformation and agility in government 3. You then have to copy the new title, go to Explorer, locate the file and rename it manually ## Problem statement * Your filename's date prefix may not match the isPublishDate for the post * Your filename's title may not match the title in the post * Users will have difficulty managing their content since the filename ultimately represents the date and title of the content. For example, sorting content will be more difficult ## Value statement * Content creators often write future posts, so this will support a common use case scenario * Content creators often change the dates and titles of their posts, so that will support a common use case scenario **Describe the solution you'd like** Ideally, there is a "Smart rename" option in FM that allows me to rename the file with the updated `datetime` that is designated as `isPublishDate` and also modify the title of the filename if that changed (I do not believe there is a `isTitle` boolean, but I assume FM always expects a title?). Optionally, offer a UI to modify the file name manually, but follow all the business rules you use to create a filename. For example, if I rename a file and type: `2023 10 03 Welcome to October!` The filename will be: `2023-10-03-welcome-to-october.md` **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** The following image represents a common use case, where I create a post where FM assumes I am going to post on the creation date. FM assumes the filename remains the same despite changing the date and title in YAML. <img width="925" alt="file-naming-issue" src="https://user-images.githubusercontent.com/15895828/226497221-6a0af2a0-5c1e-4368-8959-a26c41796049.png"> <!-- github-sync-id:1633085987 -->
adam closed this issue 2026-10-05 02:47:03 +02:00
Author
Owner

It might be related to: https://github.com/estruyf/vscode-front-matter/issues/519

There is an old frontMatter.taxonomy.alignFilename setting, which needs to be moved to the content type level, as you have more flexibility over the file alignment.

By the way: Do you use the filename as the slug?

It might be related to: https://github.com/estruyf/vscode-front-matter/issues/519 There is an old `frontMatter.taxonomy.alignFilename` setting, which needs to be moved to the content type level, as you have more flexibility over the file alignment. By the way: Do you use the filename as the slug? <!-- github-comment-id:1477480307 -->
Author
Owner

No, as a matter of fact I do not use slugs at all. I know, I know. I just haven't gotten around to it.

No, as a matter of fact I do not use slugs at all. I know, I know. I just haven't gotten around to it. <!-- github-comment-id:1478649430 -->
Author
Owner

@BillRaymond no problem, but the align filename feature will update based on the slug. Now if you don't use it, that is not a big problem, just needed to know how to link it. Will have to do some tests.

@BillRaymond no problem, but the align filename feature will update based on the slug. Now if you don't use it, that is not a big problem, just needed to know how to link it. Will have to do some tests. <!-- github-comment-id:1479147145 -->
Author
Owner

I thought about it this morning and pondered how it would work with the user interface you have designed. Here is a thought. You have a contenttype that defines how you will name your files. In this case, it is yyyy-MM-dd-title-of-podcast.md (however that gets defined).

Next, you display a warning in the SEO status area that the date and title do not match the filename, so that is just your warning.

In the Actions area, you display a button that allows the user to correct the issue by renaming the file. Of course, you could run into a situation where that filename already exists, so you might prepend it with a -1 or -2 etc, or tell the user to fix it themselves.

In my example, the filename started out as:

2023-04-04-empowering-your-workforce-as-citizen-developers.md

However, the date, which has "isPublishDate": true set in the frontmatter.json file, has been changed. Also, the title has been changed, so this is what is in the YAML now:

date: 23-05-08
title: Citizen developers

I would see an SEO error stating the filename does not match the date and title. I would also have a Rename file button.

When I press the Rename file button, the new filename will now be:

2023-05-08-citizen-developers

Thoughts?

idea-for-renaming-files
I thought about it this morning and pondered how it would work with the user interface you have designed. Here is a thought. You have a `contenttype` that defines how you will name your files. In this case, it is `yyyy-MM-dd-title-of-podcast.md` (however that gets defined). Next, you display a warning in the `SEO status` area that the date and title do not match the filename, so that is just your warning. In the `Actions` area, you display a button that allows the user to correct the issue by renaming the file. Of course, you could run into a situation where that filename already exists, so you might prepend it with a `-1` or `-2` etc, or tell the user to fix it themselves. In my example, the filename started out as: ``` 2023-04-04-empowering-your-workforce-as-citizen-developers.md ``` However, the date, which has `"isPublishDate": true` set in the `frontmatter.json` file, has been changed. Also, the title has been changed, so this is what is in the YAML now: ``` date: 23-05-08 title: Citizen developers ``` I would see an SEO error stating the filename does not match the date and title. I would also have a `Rename file` button. When I press the `Rename file` button, the new filename will now be: ``` 2023-05-08-citizen-developers ``` Thoughts? <img width="1544" alt="idea-for-renaming-files" src="https://user-images.githubusercontent.com/15895828/227240227-8b1d5545-a9ae-4193-8780-16d5e5f260b8.png"> <!-- github-comment-id:1481343255 -->
Author
Owner

Has there been any update on this issue? I also prep content in advance, so end up with my web pages having a date mismatch with the publish date.
Is there any reason I should keep the date in the web page title, this might be an easy solution, disable the date in the content title?

Has there been any update on this issue? I also prep content in advance, so end up with my web pages having a date mismatch with the publish date. Is there any reason I should keep the date in the web page title, this might be an easy solution, disable the date in the content title? <!-- github-comment-id:4150531298 -->
Author
Owner

In the latest beta, there is a new smart rename action added.

Image

It combines the publishing date + title for the filename. If you don't want the date in the filename, you'll have to change the global frontMatter.templates.prefix setting or define it on Content Type level: https://frontmatter.codes/docs/content-creation/placeholders#using-placeholders

In the latest beta, there is a new `smart rename` action added. <img width="564" height="133" alt="Image" src="https://github.com/user-attachments/assets/172a1782-aacd-427b-a47d-3f754f74a374" /> It combines the publishing date + title for the filename. If you don't want the date in the filename, you'll have to change the global `frontMatter.templates.prefix` setting or define it on Content Type level: https://frontmatter.codes/docs/content-creation/placeholders#using-placeholders <!-- github-comment-id:4154587954 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#432