All articles
astro

Fix astro RSS error which says that file has invalid or missing frontmatter.

Share this article

Share on LinkedIn Share on X (formerly Twitter)

Probably you've encountered this error message because you are using @astrojs/rss package to create RSS feed for your website

[RSS] [File path] has invalid or missing frontmatter.
Fix the following properties:
Invalid input

Solution

Check if your markdown file has following properties in it's frontmatter

  • title
  • pubDate
  • description (optional)

If you have a date property in your frontmatter, but with a different name instead of pubDate, then you need to parse it yourself.

import rss from '@astrojs/rss';
 
export async function get(context) {
  const postImportResult = import.meta.glob('../posts/**/*.md', { eager: true });
  const posts = Object.values(postImportResult);
 
  return rss({
    title: 'Buzz’s Blog',
    description: 'A humble Astronaut’s guide to the stars',
    site: context.site,
    items: blog.map((post) => ({
      link: post.url,
      pubDate: post.date
    }))
  });
}

Comments