Enhancement: Allow the frontmatter.json config to live in a sub-folder #537

Closed
opened 2026-10-05 02:51:44 +02:00 by adam · 11 comments
Owner

As some want to keep the root of their project clean, it would be helpful to allow the frontmatter.json file to live within a subfolder.

Important

: for workspaces, it would be advised to keep the frontmatter.json file in the root of the SSG project as it is used for Front Matter to know the start location.

As some want to keep the root of their project clean, it would be helpful to allow the `frontmatter.json` file to live within a subfolder. > **Important**: for workspaces, it would be advised to keep the `frontmatter.json` file in the root of the SSG project as it is used for Front Matter to know the start location. <!-- github-sync-id:1908974160 -->
adam closed this issue 2026-10-05 02:51:44 +02:00
Author
Owner

In this context, hope to

  • ’frontMatter.content.pageFolders’ can be relative to this sub-folder(where frontmatter.json is located)
  • Server(e.g. hugo) start at this sub-folder
worskpace/
└── doc
    ├── content
    ├── frontmatter.json
    └── hugo-config.toml
In this context, hope to - ’frontMatter.content.pageFolders’ can be relative to this sub-folder(where frontmatter.json is located) - Server(e.g. `hugo`) start at this sub-folder ``` worskpace/ └── doc ├── content ├── frontmatter.json └── hugo-config.toml ``` <!-- github-comment-id:1773704261 -->
Author
Owner

@n-arakawa, I see that you are using a workspace. Currently, that is not supported, as the extension will search for the frontmatter.json file to decide where the SSG project is located. Looking through sub-folders of all workspace folders complicates it a bit or could end up using the wrong folder. More work is required for that.

Feel free to open another issue for this kind of enhancement if you want to get it in the product.

@n-arakawa, I see that you are using a workspace. Currently, that is not supported, as the extension will search for the `frontmatter.json` file to decide where the SSG project is located. Looking through sub-folders of all workspace folders complicates it a bit or could end up using the wrong folder. More work is required for that. Feel free to open another issue for this kind of enhancement if you want to get it in the product. <!-- github-comment-id:1774603073 -->
Author
Owner

Thank you for your answer.
I may have confused

  • SSG project
  • VScode workspace
  • git repository
Thank you for your answer. I may have confused - SSG project - VScode workspace - git repository <!-- github-comment-id:1776117643 -->
Author
Owner

Sorry, @n-arakawa, now I got confused too, could you share your project repository its folders, and where in the structure the frontmatter.json file is located?

Sorry, @n-arakawa, now I got confused too, could you share your project repository its folders, and where in the structure the `frontmatter.json` file is located? <!-- github-comment-id:1777260114 -->
Author
Owner

Sorry for my poor explonation.
In this case I do not use VScode workspace.
The folder name "workspace" in the previous post is incorrect.

I have a git repository (repo1) and a documentation subdirectory (i.e. hugo-doc).

repo1/
└── hugo-doc
    ├── config.toml
    ├── content
    │   └── post
    │       └── first_post.md
    ├── frontmatter.json

When I start code repo1/hugo-doc, frontmatter works fine.
However if I say code repo1

  • Cannot find content directory. This is because content must exist directly under [[workspace]].
  • Cannnot start hugo server. This is because hugo server start at [[workspace]] and there is no hugo config(config.toml)

I hope to:

  • Set "content" relative to "frontmatter.json"
  • Start hugo server in frontmatter.json directory

frontmatter.json

{
  "$schema": "https://frontmatter.codes/frontmatter.schema.json",
  "frontMatter.framework.id": "hugo",
  "frontMatter.content.publicFolder": "static",
  "frontMatter.preview.host": "http://localhost:1313",
  "frontMatter.content.pageFolders": [{
    "title": "content",
    "path": "[[workspace]]/content",
    "previewPath": "/{{pathToken.relPath}}/",
    "contentTypes": ["post"]
  }],
  "frontMatter.taxonomy.dateFormat": "yyyy-MM-dd",
  "frontMatter.framework.startCommand": "hugo server -D"
}

Frontmatter version
[9.3.0] - 2023-10-06 - Release notes

Sorry for my poor explonation. In this case I do not use `VScode workspace.` The folder name "workspace" in the previous post is incorrect. I have a git repository (`repo1`) and a documentation subdirectory (i.e. `hugo-doc`). ``` repo1/ └── hugo-doc ├── config.toml ├── content │   └── post │   └── first_post.md ├── frontmatter.json ``` When I start `code repo1/hugo-doc`, `frontmatter` works fine. However if I say `code repo1` - Cannot find `content` directory. This is because `content` must exist directly under `[[workspace]]`. - Cannnot start hugo server. This is because hugo server start at `[[workspace]]` and there is no hugo config(`config.toml`) I hope to: - Set "content" relative to "frontmatter.json" - Start hugo server in `frontmatter.json` directory frontmatter.json ``` { "$schema": "https://frontmatter.codes/frontmatter.schema.json", "frontMatter.framework.id": "hugo", "frontMatter.content.publicFolder": "static", "frontMatter.preview.host": "http://localhost:1313", "frontMatter.content.pageFolders": [{ "title": "content", "path": "[[workspace]]/content", "previewPath": "/{{pathToken.relPath}}/", "contentTypes": ["post"] }], "frontMatter.taxonomy.dateFormat": "yyyy-MM-dd", "frontMatter.framework.startCommand": "hugo server -D" } ``` Frontmatter version [9.3.0] - 2023-10-06 - [Release notes](https://beta.frontmatter.codes/updates/v9.3.0) <!-- github-comment-id:1780170062 -->
Author
Owner

Thank you, @n-arakawa. This clarifies it.

Front Matter is intended to start from the root project folder or a VS Code Workspace, where it will look for the folders where it can find the frontmatter.json file.

As you are opening it one level up and not using a VS Code Workspace, these checks are not passed, and that is why the [[workspace]] path will be /repo1.

I'm unsure of the best approach to support your use case, as it would complicate the logic of getting to know the start location.

Thank you, @n-arakawa. This clarifies it. Front Matter is intended to start from the root project folder or a VS Code Workspace, where it will look for the folders where it can find the `frontmatter.json` file. As you are opening it one level up and not using a VS Code Workspace, these checks are not passed, and that is why the `[[workspace]]` path will be `/repo1`. I'm unsure of the best approach to support your use case, as it would complicate the logic of getting to know the start location. <!-- github-comment-id:1780581324 -->
Author
Owner

I understand that it's difficult to accommodate my use case.
In the short term, I'll disable FrontMatter in the repo1 workspace to suppressFolder "${folder.title} (${folder.path})" does not exist. Please remove it from the settings. notifications.

I understand that it's difficult to accommodate my use case. In the short term, I'll disable FrontMatter in the repo1 workspace to suppress`Folder "${folder.title} (${folder.path})" does not exist. Please remove it from the settings.` notifications. <!-- github-comment-id:1780816407 -->
Author
Owner

@n-arakawa when you open the repo1 folder, is that because there are more folders in it that you want to work with?

@n-arakawa when you open the `repo1` folder, is that because there are more folders in it that you want to work with? <!-- github-comment-id:1781032618 -->
Author
Owner

@estruyf

is that because there are more folders in it that you want to work with?

yes. My "repo1" is not just a documentation project, it's a software project in itself. I plan to manage the documentation part of the project with vscode-front-matter.

@estruyf > is that because there are more folders in it that you want to work with? yes. My "repo1" is not just a documentation project, it's a software project in itself. I plan to manage the documentation part of the project with vscode-front-matter. <!-- github-comment-id:1781950673 -->
Author
Owner

What holds you from creating a VS Code Workspace? That way, you could open repo1 as a workspace with all the folders.

What holds you from creating a VS Code Workspace? That way, you could open `repo1` as a workspace with all the folders. <!-- github-comment-id:1782392977 -->
Author
Owner

Thank you for your advice!
Creating a workspace with two folders "repo1" and "repo1/hugo-doc" seems to solve the problem.

Thank you for your advice! Creating a workspace with two folders "repo1" and "repo1/hugo-doc" seems to solve the problem. <!-- github-comment-id:1783596805 -->
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#537