Overview of svelte-meta-tags
mainsvelte-meta-tags is a library designed to manage SEO and meta tags within Svelte applications. It helps developers automate and manage the metadata required to boost SEO and social media visibility.repository·main·Indexed 20 days ago
https://github.com/oekazuma/svelte-meta-tagsA utility library for Svelte applications to simplify the management of SEO and meta tags. It provides the <MetaTags /> component for managing titles, descriptions, canonical URLs, and Open Graph metadata, as well as the <JsonLd /> component for injecting structured data (JSON-LD) with full TypeScript support via schema-dts. Key features include deep merge functionality for complex applications and dedicated agent skills for setup and code improvement.
svelte-meta-tags is a library designed to manage SEO and meta tags within Svelte applications. It helps developers automate and manage the metadata required to boost SEO and social media visibility.Svelte Meta Tags is a library providing a set of Svelte components designed to manage SEO meta tags and structured data effortlessly.
Key features include:
MetaTags uses a titleTemplate to format the page title. The %s placeholder is globally replaced by the title value. If title is not provided, nothing is output even if a titleTemplate exists.
twitter.title $\rightarrow$ openGraph.title $\rightarrow$ updatedTitle (the formatted title).twitter.description $\rightarrow$ openGraph.description $\rightarrow$ description.og:url $\rightarrow$ openGraph.url or canonical.og:title $\rightarrow$ openGraph.title or updatedTitle.og:description $\rightarrow$ openGraph.description or description.'index,follow'.robots is set to false, the <meta name="robots"> tag is omitted entirely.additionalRobotsProps when robots is falsy will trigger a console warning.The JsonLd component renders JSON-LD structured data.
output prop defaults to 'head'. Setting it to 'body' renders the script at the component's location instead of inside <svelte:head>.schema is an array, it renders each element.schema is a single object (including {'@graph': [...]} formats), it automatically adds '@context': 'https://schema.org'.<script> tag is rendered using string concatenation ('<scri' + 'pt ...>') to prevent HTML parsers from misidentifying it during build/processing.You can render multiple schemas using two methods:
schema prop. This renders multiple <script> blocks or multiple objects within one block.{ '@graph': [...] }. This represents them as a single linked graph. This is the recommended approach because some tools (like Safari) may log console errors when encountering the plain array form, even if it functions correctly.The MetaTag type is a union type that represents the different categories of meta tags supported by the library. It encompasses standard HTML5 meta tags, RDFa meta tags, and HTTP-equivalent meta tags. When working with the library's APIs, you will likely be providing objects that conform to one of these three specific subtypes.
type MetaTag = HTML5MetaTag | RDFaMetaTag | HTTPEquivMetaTag;When using additionalMetaTags, be aware of how tags are rendered and merged:
additionalMetaTags array. If you provide multiple entries with the same name, property, or httpEquiv, both will be rendered in the HTML.deepMerge: If you are combining base (layout-level) and page-level meta tags using deepMerge, the additionalMetaTags array is replaced rather than concatenated. A page-level additionalMetaTags array will completely overwrite the layout-level array. This behavior prevents duplicate tags across different layers but requires you to define all necessary additional tags at the page level if you want to override the layout.schema prop is type-checked using schema-dts. This means every schema.org type is available with full TypeScript support. You can find a list of available schema types in Google's Search Gallery.Blume uses the file system to automatically generate the sidebar. To control the organization and order of your documentation:
content/ (for English) and ja/ (for Japanese). Use meta.ts files within folders to manage group-level metadata.sidebar.order field in the page's frontmatter.order field within the defineMeta function in the folder's meta.ts file.Open Graph or JSON-LD) where labels are identical across languages, use meta.$.ts to share metadata across all locales and avoid duplication in the ja/ directory.In blume, sidebar organization is handled via meta.ts or meta.$.ts files within content folders.
meta.$.ts (Shared Groups): Use this file for groups that share the same label across all locales (e.g., Open Graph, JSON-LD). It is placed in the folder and automatically applied to all language subdirectories.meta.ts (Locale-specific Groups): Use this file when a group needs a translated label for a specific language (e.g., 'Types' vs '型定義').order property within defineMeta to control the sequence of groups and pages.sidebar.order property in the page's frontmatter.// docs/content/meta-tags-properties/meta.ts
import { defineMeta } from 'blume';
export default defineMeta({
title: 'MetaTags Properties',
order: 1
});twitter.title ?? openGraph.title ?? title). The <MetaTags> component handles this logic internally, following the precedence: twitter.title $\rightarrow$ openGraph.title $\rightarrow$ title (applying titleTemplate where applicable).The <MetaTags> and <JsonLd> components are not tied to SvelteKit internals. They work in any Svelte project by writing directly into <svelte:head> (or inlining when using <JsonLd output="body">).
While the library provides SvelteKit-specific patterns using load-based files (+layout.ts, +page.ts) and deepMerge, in a plain Svelte application, you should simply pass your data directly to the <MetaTags> props from your own data-fetching logic.