Skip to content

SEO and SMO meta tags

Astro plugins

Those are the most popular plugins for the task:

  • astro-seo ↗ This Astro component makes it easy to add tags that are relevant for search engine optimization (SEO) to your pages.
  • @astrolib/seo ↗ Astro SEO is an integration that makes managing your SEO easier in Astro projects. It is fully based on the excellent Next SEO library
  • astro-seo-meta ↗ Astro seo provides an Seo component to update meta tags.
  • astro-seo-schema ↗ Easily insert valid Schema.org JSON-LD in your Astro apps.

Metadata

type: NewsArticle

  1. Install dependencies

    Terminal window
    pnpm add schema-dts astro-seo-schema
  2. Add Schema to Head

    src/components/Head.astro
    ---
    import type { Props } from "@astrojs/starlight/props";
    import Default from "@astrojs/starlight/components/Head.astro";
    import { Schema } from "astro-seo-schema";
    ---
    <Default {...Astro.props}><slot /></Default>
    <Schema
    item={{
    "@context": "https://schema.org",
    "@type": "NewsArticle",
    dateModified: Astro.props.lastUpdated?.toISOString(),
    headline: Astro.props.entry.data.title,
    author: [
    {
    "@type": "Person",
    name: "stereobooster",
    url: "https://stereobooster.com",
    },
    ],
    }}
    />
  3. Change Astro config

    astro.config.mjs
    export default defineConfig({
    integrations: [
    starlight({
    components: {
    Head: "./src/components/Head.astro",
    },
    lastUpdated: true,
    }),
    ],
    });

type: Article

Try "@type":"Article" plus:

  • <article>
  • <span itemprop="dateModified" content="2020-Mar-13">
  • <h1 itemprop="name">...</h1>
  • <div itemprop="articleBody">...</div>

Sites to test meta tags

TODO

  • plugin that places sitempa URL in robots.txt (astro-robots-txt)
  • use updated at date in sitemap (so search engine would rescan those pages first)