Enhancement: Astro new assets location #485

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

In Astro added a new location for asset management src/assets. When this feature is enabled, the images added to this folder should be relatively referenced to the content folder/file.

Example:

---
title: 'First post'
description: 'Lorem ipsum dolor sit amet'
pubDate: 'Jul 08 2022'
heroImage: '../../assets/blog-placeholder-1.jpg'
---

![](../../assets/blog-placeholder-1.jpg)

https://docs.astro.build/en/guides/assets/

In Astro added a new location for asset management `src/assets`. When this feature is enabled, the images added to this folder should be relatively referenced to the content folder/file. Example: ```markdown --- title: 'First post' description: 'Lorem ipsum dolor sit amet' pubDate: 'Jul 08 2022' heroImage: '../../assets/blog-placeholder-1.jpg' --- ![](../../assets/blog-placeholder-1.jpg) ``` https://docs.astro.build/en/guides/assets/ <!-- github-sync-id:1837993649 -->
adam closed this issue 2026-10-05 02:49:39 +02:00
Author
Owner
  • Check if we can allow multiple asset folders in the frontMatter.content.publicFolder setting
  • Add the astro:assets as a frontMatter.content.publicFolder option. If this is used, the files will be added relative to the content folder/page.
  • Breadcrumb
- [ ] Check if we can allow multiple asset folders in the `frontMatter.content.publicFolder` setting - [x] ~Add the `astro:assets` as a `frontMatter.content.publicFolder` option. If this is used, the files will be added relative to the content folder/page.~ - [x] Breadcrumb <!-- github-comment-id:1666661124 -->
Author
Owner

To use the new Astro Assets feature, you will need to configure the frontMatter.content.publicFolder setting with the following value: astro:assets.

~To use the new Astro Assets feature, you will need to configure the `frontMatter.content.publicFolder` setting with the following value: `astro:assets`.~ <!-- github-comment-id:1666677875 -->
Author
Owner

Thinking more about it, to be more future-proof, it would be better to enhance the frontMatter.content.publicFolder setting as I just read the following on the Astro docs:

We recommend storing all images to be optimized in the src/assets/ directory to make use of our official ~/assets alias, although this location is optional.

Right now the setting expects a string, but might be better to be an object which defines the folder + if it needs to be a relative path or not.

{
  "frontMatter.content.publicFolder": {
    "path": "src/assets",
    "relative": true
  }
}
Thinking more about it, to be more future-proof, it would be better to enhance the `frontMatter.content.publicFolder` setting as I just read the following on the Astro docs: > We recommend storing all images to be optimized in the src/assets/ directory to make use of our official ~/assets alias, *although this location is optional*. Right now the setting expects a string, but might be better to be an object which defines the folder + if it needs to be a relative path or not. ```json { "frontMatter.content.publicFolder": { "path": "src/assets", "relative": true } } ``` <!-- github-comment-id:1666860974 -->
Author
Owner

The above setting is implemented in the latest beta. During the welcome experience, you will also have the option to pick the asset folder.

image

The above setting is implemented in the latest beta. During the welcome experience, you will also have the option to pick the asset folder. ![image](https://github.com/estruyf/vscode-front-matter/assets/2900833/51a1a1d2-8d77-4e22-a235-21b26f91b4d9) <!-- github-comment-id:1666945121 -->
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#485