Skip to content

SEO and SMO meta tags

Astro Plugins

These are the most popular plugins for the task:

  • astro-seo β†—: This Astro component makes it easy to add tags 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" with the following elements:

  • <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 sitemap URL in robots.txt (astro-robots-txt)
  • Use the β€œupdated at” date in the sitemap (so search engines would rescan those pages first)
    • Maybe I can use BrainDb to generate it?