Skip to content

Confusing warning for images in /pages directory: Unsupported file type /src/pages/img/my-image.jpg found. #14321

@fwextensions

Description

@fwextensions

Astro Info

Astro                    v5.13.5
Node                     v24.4.1
System                   Windows (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I've created a few Astro sites, but only work on them sporadically. I came back to one and wanted to add a markdown file that linked to lots of local images. So I thought, "I'll just put these images in /src/pages/my-new-md-page/img/, since they all have a ./img/image-name.jpg path from the markdown file".

Everything rendered fine, but I was seeing all these warnings in the console:

[WARN] Unsupported file type \path\to\src\pages\my-new-md-page\img\photo-1.jpg found. Prefix filename with an underscore (`_`) to ignore.

(Yes, this is on Windows.)

So that sent me down a rabbit hole of trying to figure out why these image files were of an unsupported type. Did it not like the .jpg extension? Could other apps open the images? Is there something about the file that the Astro image processing pipeline didn't like?

Eventually I realized, duh, it's just complaining about non-page file types being stored in the special /pages directory. Which makes sense, but the error message is very confusing when you're new to Astro, or just rusty.

What's the expected result?

A clearer warning would be helpful. Something like:

[WARN] The /pages directory is intended only for page source files. Prefix filename with an underscore (`_`) to ignore. Found: <non-page file path>

Basically, some hint that the issue is the /pages directory is special, and there's nothing inherently wrong with the files it's warning about. Bonus points for detecting asset file types (images, CSS, etc.) and suggesting they go in a /src/assets directory or something.

Link to Minimal Reproducible Example

N/A

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P2: nice to haveNot breaking anything but nice to have (priority)feat: routingRelated to Astro routing (scope)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions