#content pages upgrading from astro4 to 5

7 messages · Page 1 of 1 (latest)

crisp verge
#

I upgraded with the tooling and got errors. I see nothing really referencing this in the migration guides or breaking changes. What is going on?

Error messages (left some near duplicate lines out because message was" too long"):

11:19:18 [content] Syncing content
11:19:18 [ERROR] [glob-loader] Error reading en:about.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading en:concerts.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading en:contact.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading en:home.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading en:media.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading en:news.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading sv:about.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading sv:concerts.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading sv:home.md: The URL must be of scheme file
11:19:18 [WARN] [glob-loader] No contents found for en:about.md
11:19:18 [WARN] [glob-loader] No contents found for en:concerts.md
11:19:18 [WARN] [glob-loader] No contents found for en:contact.md
11:19:18 [WARN] [glob-loader] No contents found for en:home.md
11:19:18 [WARN] [glob-loader] No contents found for en:media.md
11:19:18 [WARN] [glob-loader] No contents found for en:news.md
11:19:18 [WARN] [glob-loader] No contents found for sv:about.md
11:19:18 [WARN] [glob-loader] No contents found for sv:concerts.md
11:19:18 [WARN] [glob-loader] No contents found for sv:home.md
11:19:18 [ERROR] [glob-loader] Error reading sv:media.md: The URL must be of scheme file
11:19:18 [ERROR] [glob-loader] Error reading sv:news.md: The URL must be of scheme file
11:19:18 [WARN] [glob-loader] No contents found for sv:media.md
11:19:18 [WARN] [glob-loader] No contents found for sv:news.md
11:19:18 [content] Synced content

wet sapphireBOT
#

Hi @crisp verge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information in the official Astro upgrade guides and references, your error messages after upgrading from Astro 4 to 5 are likely related to changes in the content collections system and the new Content Layer API introduced in Astro 5.0.

Key Points from the Migration Guide

  • Astro 5.0 introduces a new Content Layer API for content collections, replacing the legacy v2.0 Content Collections API. While legacy collections are still supported with some backward compatibility, there are breaking changes and limitations. For example, all collections must now be defined in src/content.config.ts, and the way loaders and file paths are handled has changed. The new system uses the glob() loader, which expects file paths and patterns to be specified correctly, and the base property should be a valid file path or URL with the file scheme [Upgrade to Astro v5 – Legacy].

  • Error: "The URL must be of scheme file"
    This error suggests that the base property or file paths in your content loader configuration are not being interpreted as valid file URLs. In Astro 5, when using the glob() loader, the base property should be a string path (relative to your project root) or a file:// URL. If you are passing something else (like a plain string that isn't a valid path, or a URL with a different scheme), you will get this error [Content Loader Reference].

#
  • What should you do?
    1. Check your src/content.config.ts file:
      Ensure that all collections are defined here, and that the base property in your glob() loader is a valid relative path (e.g., "./src/content/pages") or a file:// URL.
    2. Update legacy collection definitions:
      If you are still using the old type: 'content' or type: 'data' properties, migrate to the new loader-based system as soon as possible. See the migration steps for updating collections [Upgrade to Astro v5 – What should I do?].
    3. File paths and globs:
      Double-check your glob patterns and base paths. They must be valid and relative to the base directory you specify. Invalid globs or paths will cause errors [Invalid glob pattern].

Example of Correct Loader Usage

import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';

const pages = defineCollection({
  loader: glob({ pattern: "**/*.md", base: "./src/content/pages" }),
  schema: /* ... */
});

Make sure "./src/content/pages" exists and contains your Markdown files.

Summary

Your errors are likely due to misconfigured loader paths or glob patterns in your new content config. Review and update your src/content.config.ts to use valid file paths and the new loader system. If you are unable to migrate immediately, you can enable the legacy.collections flag for temporary compatibility, but migration is strongly recommended [Upgrade to Astro v5 – What should I do?].

If you continue to have issues, check for any custom logic or plugins that may be passing invalid URLs or paths to the loader.

#

If you need more specific help, please share your src/content.config.ts file and the structure of your content directories.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@crisp verge Kapa.ai is still learning and improving, please let me know how I did by reacting below.

crisp verge
#

ah, the new collections thing, i realize now. i'll read upon it