Issue: Media URLs are inserted relative to repo root instead of the public directory #282

Closed
opened 2026-10-05 02:37:37 +02:00 by adam · 4 comments
Owner

Describe the bug

Using the FrontMatter UI for a field with type "image", the inserted path is relative to the project root instead of "frontMatter.content.publicFolder", making it so that direct use of the image URL by my website is not possible (for the running site, the URLs are relative to the public folder, not to the repo root).

This is something in between a bug (since the current behavior is surprising and has no workaround) and a feature request (since it might currently be working as intended).

To Reproduce
Steps to reproduce the behavior:

  1. Add images to a static directory projects/site/static
  2. Set "frontMatter.content.publicFolder" to projects/site/static
  3. Add an image field to the default content-type, e.g.
{
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "fileType": "md",
      "fields": [
        {
          "title": "Image Path",
          "name": "url",
          "type": "image",
          "isPreviewImage": true
        }
      ]
    }
  ]
}
  1. In a Markdown file, open the Front Matter sidebar and scroll to the Image Path field
  2. Click the image icon, browse for an image.
  3. Hover over the vertical '...' and click the + icon to insert the path
  4. Observe that the inserted path starts with projects/site/static

Expected behavior

I expect the "frontMatter.taxonomy.contentTypes" part of the path to be excluded from the inserted path, since all paths for the actual content are relative to the publicFolder root, not the repo root.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11 (Insiders)
  • Browser: Chrome (latest)
  • FrontMatter Version: latest of both release and beta extensions
**Describe the bug** Using the FrontMatter UI for a field with type "image", the inserted path is relative to the project root instead of `"frontMatter.content.publicFolder"`, making it so that direct use of the image URL by my website is not possible (for the running site, the URLs are relative to the public folder, not to the repo root). This is something in between a bug (since the current behavior is surprising and has no workaround) and a feature request (since it might currently be working as intended). **To Reproduce** Steps to reproduce the behavior: 1. Add images to a static directory `projects/site/static` 2. Set `"frontMatter.content.publicFolder"` to `projects/site/static` 3. Add an image field to the default content-type, e.g. ```json { "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": false, "fileType": "md", "fields": [ { "title": "Image Path", "name": "url", "type": "image", "isPreviewImage": true } ] } ] } ``` 4. In a Markdown file, open the Front Matter sidebar and scroll to the Image Path field 5. Click the image icon, browse for an image. 6. Hover over the vertical '...' and click the `+` icon to insert the path 7. Observe that the inserted path starts with `projects/site/static` **Expected behavior** I expect the "frontMatter.taxonomy.contentTypes" part of the path to be excluded from the inserted path, since all paths for the actual content are relative to the publicFolder root, not the repo root. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: Windows 11 (Insiders) - Browser: Chrome (latest) - FrontMatter Version: latest of both release and beta extensions <!-- github-sync-id:1268653553 -->
adam closed this issue 2026-10-05 02:37:37 +02:00
Author
Owner

Hi @adam-coster, thank you for opening this issue. Paths inserted to the content should be relative to the publicFolder or page bundle.

Questions

In order for us to reproduce the issue, would you be able to share a bit more details?

  • I see you have a projects/site/static set for the public folder, where does the content live?
  • Is projects the root of your solution you are opening in VS Code?
Hi @adam-coster, thank you for opening this issue. Paths inserted to the content should be relative to the `publicFolder` or page bundle. **Questions** In order for us to reproduce the issue, would you be able to share a bit more details? - I see you have a `projects/site/static` set for the public folder, where does the content live? - Is `projects` the root of your solution you are opening in VS Code? <!-- github-comment-id:1153549605 -->
Author
Owner

To try to reproduce the issue, I configured the site as follows:

folders

  • root
    • blog (the markdown pages)
    • projects
      • site
        • static

frontmatter.json

{
  "$schema": "https://beta.frontmatter.codes/frontmatter.schema.json",
  "frontMatter.framework.id": "docusaurus",
  "frontMatter.content.publicFolder": "projects/site/static",
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "fields": [
        {
          "title": "Image Path",
          "name": "url",
          "type": "image",
          "isPreviewImage": true
        }
      ]
    }
  ]
}

Image path

image

To try to reproduce the issue, I configured the site as follows: **folders** - root - blog (the markdown pages) - projects - site - static **frontmatter.json** ```json { "$schema": "https://beta.frontmatter.codes/frontmatter.schema.json", "frontMatter.framework.id": "docusaurus", "frontMatter.content.publicFolder": "projects/site/static", "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": false, "fields": [ { "title": "Image Path", "name": "url", "type": "image", "isPreviewImage": true } ] } ] } ``` **Image path** ![image](https://user-images.githubusercontent.com/2900833/173302975-03ee46f4-5647-47f3-8468-43dd7ac8e358.png) <!-- github-comment-id:1153579800 -->
Author
Owner

Found the issue. It had to do with some Windows file parsing. It should be fixed in the v7.3.4.

Found the issue. It had to do with some Windows file parsing. It should be fixed in the `v7.3.4`. <!-- github-comment-id:1153625331 -->
Author
Owner

Rad, thanks for the quick fix!

Rad, thanks for the quick fix! <!-- github-comment-id:1154003834 -->
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#282