Enhancement: define filename prefixes on folder level #368

Closed
opened 2026-10-05 02:43:18 +02:00 by adam · 10 comments
Owner

Discussed in https://github.com/estruyf/vscode-front-matter/discussions/452

Originally posted by rshmhrj November 6, 2022
Hi all!
First -- thanks for all the work on this awesome extension. I have found it extremely useful in setting up and maintaining the site. The more I use it, and the more familiar I am getting with the settings, the better it gets!

Context:

I have two sections in my Hugo site: posts and references. From the front matter dashboard, clicking create content pops up a question asking which folder to add the content to, what to title it, and then it auto creates the file based on a template.

It also slugifies the title and prepends the date for the filename.

For posts, I like the auto dating behavior. For references, I want to disable it.

Question

Is there a config setting to selectively enable/disable the auto-dating based on which folder is selected?

Obviously, the "workaround" is to create it and then manually delete the date portion of the filename (which takes 2 seconds), but just wondering if such a feature / configuration exists. I searched through the existing issues and discussions , but didn't find anything specifically related to the folder choice.

Thanks again!

### Discussed in https://github.com/estruyf/vscode-front-matter/discussions/452 <div type='discussions-op-text'> <sup>Originally posted by **rshmhrj** November 6, 2022</sup> Hi all! First -- thanks for all the work on this awesome extension. I have found it extremely useful in setting up and maintaining the site. The more I use it, and the more familiar I am getting with the settings, the better it gets! ### Context: I have two sections in my Hugo site: `posts` and `references`. From the front matter dashboard, clicking `create content` pops up a question asking which folder to add the content to, what to title it, and then it auto creates the file based on a template. **It also slugifies the title and prepends the date for the filename.** For `posts`, I like the auto dating behavior. For `references`, I want to disable it. ### Question **Is there a config setting to selectively enable/disable the auto-dating based on which folder is selected?** Obviously, the "workaround" is to create it and then manually delete the date portion of the filename (which takes 2 seconds), but just wondering if such a feature / configuration exists. I searched through the existing issues and [discussions](https://github.com/estruyf/vscode-front-matter/discussions/252) , but didn't find anything specifically related to the folder choice. Thanks again!</div> <!-- github-sync-id:1439689112 -->
adam closed this issue 2026-10-05 02:43:18 +02:00
Author
Owner

This is now available in the beta for you to try out by setting the filePrefix on the folder setting.

"frontMatter.content.pageFolders": [
  {
    "title": "blog",
    "path": "[[workspace]]/blog",
    "filePrefix": "yyyy-MM-dd"
  },
  {
    "title": "docs",
    "path": "[[workspace]]/docs",
    "filePrefix": ""
  }
]
This is now available in the beta for you to try out by setting the `filePrefix` on the folder setting. ```json "frontMatter.content.pageFolders": [ { "title": "blog", "path": "[[workspace]]/blog", "filePrefix": "yyyy-MM-dd" }, { "title": "docs", "path": "[[workspace]]/docs", "filePrefix": "" } ] ``` <!-- github-comment-id:1308717541 -->
Author
Owner

Thanks for working on this @estruyf -- really appreciate the quick turnaround! Tested it out and it seems to work perfectly.

Testing steps:

  • Used vscodium not vs-code

  • Uninstalled FM and installed beta version.

    • Note: name in marketplace is Front Matter CMS (BETA) v8.2.3428349. I expected it to be VS Code Marketplace - Front Matter BETA per the Readme
      image
  • Starting pageFolders structure:

    "frontMatter.content.pageFolders": [
      {
        "title": "posts",
        "path": "[[workspace]]/content/posts"
      },
      {
        "title": "refs",
        "path": "[[workspace]]/content/refs"
      }
    ],
    
  • Result

    • Created test1 in both posts and refs
    • Both files were autonamed to 2022-11-10-test1.md
  • Updated pageFolders structure:

    "frontMatter.content.pageFolders": [
     {
       "title": "posts",
       "path": "[[workspace]]/content/posts",
       "filePrefix": "yyyy-MM-dd"
     },
     {
       "title": "refs",
       "path": "[[workspace]]/content/refs",
       "filePrefix": ""
     }
    ],
    
  • Result

    • Created test2 in both posts and refs
    • File in posts was named 2022-11-10-test2.md
    • File in refs was named test2.md

/lgtm

Thanks for working on this @estruyf -- really appreciate the quick turnaround! Tested it out and it seems to work perfectly. Testing steps: - Used `vscodium` not `vs-code` - Uninstalled FM and installed beta version. - _Note: name in marketplace is `Front Matter CMS (BETA)` v8.2.3428349. I expected it to be `VS Code Marketplace - Front Matter BETA` per the [Readme](https://github.com/estruyf/vscode-front-matter/blob/main/README.md?plain=1#L119)_ ![image](https://user-images.githubusercontent.com/750874/201273282-d28ba706-c8c5-47d3-b524-b3fcbae5e6b0.png) - Starting `pageFolders` structure: ```json "frontMatter.content.pageFolders": [ { "title": "posts", "path": "[[workspace]]/content/posts" }, { "title": "refs", "path": "[[workspace]]/content/refs" } ], ``` - Result - Created `test1` in both `posts` and `refs` - Both files were autonamed to `2022-11-10-test1.md` - Updated `pageFolders` structure: ```json "frontMatter.content.pageFolders": [ { "title": "posts", "path": "[[workspace]]/content/posts", "filePrefix": "yyyy-MM-dd" }, { "title": "refs", "path": "[[workspace]]/content/refs", "filePrefix": "" } ], ``` - Result - Created `test2` in both `posts` and `refs` - File in `posts` was named `2022-11-10-test2.md` - File in `refs` was named `test2.md` /lgtm <!-- github-comment-id:1311269971 -->
Author
Owner

@estruyf the only minor issue I'm seeing with it is the squiggly line, and the message about filePrefix not being allowed here:
image

@estruyf the only minor issue I'm seeing with it is the squiggly line, and the message about `filePrefix` not being allowed here: ![image](https://user-images.githubusercontent.com/750874/201292200-665a4f72-4e91-4981-af39-d6ab83f46fe0.png) <!-- github-comment-id:1311350378 -->
Author
Owner

@rshmhrj no worries, this is because both beta and main schema have not been updated. That is the reason why you experience this. More important is that the functionality is working as expected.

@rshmhrj no worries, this is because both beta and main schema have not been updated. That is the reason why you experience this. More important is that the functionality is working as expected. <!-- github-comment-id:1312566155 -->
Author
Owner

Hi @estruyf,
Played around with it some more and found that if I set
frontMatter.taxonomy.contentTypes[0].pageBundle = true
simultaneously with
frontMatter.content.pageFolders[0].filePrefix = yyyy-MM-dd
the result is a pageBundle without the date prefix

flipping frontMatter.taxonomy.contentTypes[0].pageBundle = false
results in the standalone .md file with the date prefix.

Hi @estruyf, Played around with it some more and found that if I set `frontMatter.taxonomy.contentTypes[0].pageBundle` = `true` simultaneously with `frontMatter.content.pageFolders[0].filePrefix` = `yyyy-MM-dd` the result is a pageBundle without the date prefix flipping `frontMatter.taxonomy.contentTypes[0].pageBundle` = `false` results in the standalone `.md` file with the date prefix. <!-- github-comment-id:1312686040 -->
Author
Owner

Thanks @rshmhrj, this functionality was indeed not yet implemented. It should have been fixed.

Thanks @rshmhrj, this functionality was indeed not yet implemented. It should have been fixed. <!-- github-comment-id:1313390604 -->
Author
Owner

Yes! Tested it and it works with the bundle and with/without dates as expected!

Thanks so much @estruyf !! 😄

Yes! Tested it and it works with the bundle and with/without dates as expected! Thanks so much @estruyf !! 😄 <!-- github-comment-id:1313519963 -->
Author
Owner

Thank you @rshmhrj for testing it out and providing the feedback!

Thank you @rshmhrj for testing it out and providing the feedback! <!-- github-comment-id:1313547729 -->
Author
Owner

Shouldn't such a setting be ContentType specific rather than folder specific?

Shouldn't such a setting be ContentType specific rather than folder specific? <!-- github-comment-id:1335080445 -->
Author
Owner

@dennisl68-castra we should also support having it on a content-type level, so that it is up to the user to decide. Like with the preview URL option, these can be defined globally, folder, and content-type level.

@dennisl68-castra we should also support having it on a content-type level, so that it is up to the user to decide. Like with the preview URL option, these can be defined globally, folder, and content-type level. <!-- github-comment-id:1335260587 -->
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#368