To Keep It Going, Please Show Your Love.Buy Me a Coffee at ko-fi.com

Runes Meta Tags

Runes Meta Tags is a powerful meta tag management library for SvelteKit applications. It provides an elegant way to configure SEO meta tags, Open Graph tags for social media sharing, Twitter Cards, and more. With built-in support for deep merging, you can define default meta tags at the layout level and override them on specific pages.

Features #

  • โœจ Easy-to-use API with TypeScript support
  • ๐Ÿ”„ Deep merge support for inheriting and overriding meta tags
  • ๐ŸŒ Full Open Graph protocol support
  • ๐Ÿฆ Twitter Card meta tags
  • ๐Ÿค– Robots meta tag configuration
  • ๐Ÿ“ฑ Responsive social media images
  • ๐ŸŽฏ Article, video, and other content type support
  • ๐Ÿ”— Canonical URL support
  • ๐Ÿงช Helper functions for consistent meta tag generation

Installation #

Quick Start Guide #

Step 1: Configure Layout Server #

Create a +layout.server.ts file to define your default meta tags. These will be used across all pages unless overridden.

Step 2: Setup Layout Component #

Import MetaTags and deepMerge in your +layout.svelte. The deepMerge function intelligently combines layout and page-specific meta tags.

Step 3: Create Page-Specific Meta Tags (Optional) #

Override meta tags for specific pages by creating a +page.ts file. Only include the properties you want to change - everything else inherits from the layout.

Step 4: Use in Your Page Component #

Your page components don't need any special code - the meta tags are handled automatically!

Advanced Usage #

Using Helper Functions #

The library provides helpful utility functions to generate consistent meta tags:

Deep Merge Behavior #

Understanding how deepMerge works is important for effective meta tag management:

Keywords Configuration #

Keywords can be defined as a string or array and are automatically inherited from layout unless overridden:

Article Meta Tags #

For blog posts and articles, use the article type with additional metadata:

Video Content #

Configure video meta tags for rich video previews:

Robots Configuration #

Control how search engines index your pages:

Twitter Card Types #

Different Twitter Card types for various content:

Testing with Playwright #

Index Page Tests #

Example tests for your home page meta tags:

Page-Specific Tests #

Test that page-specific meta tags override layout defaults correctly:

API Reference #

MetaProps Interface #

Complete type definition for meta tag configuration:

Best Practices #

โœ“ DO:
  • Define common meta tags (keywords, site name, default image) in +layout.server.ts
  • Use deepMerge to inherit layout meta tags on pages
  • Always include og:url using url.href in page-specific +page.ts
  • Use helper functions for consistent title and description formats
  • Test your meta tags with Playwright
  • Provide meaningful image alt text for accessibility
โœ— DON'T:
  • Duplicate the entire meta tag structure on every page
  • Forget to add og:url to page-specific meta tags
  • Use the deprecated RunesMetaTags component (use MetaTags instead)
  • Hardcode URLs - always use url.href for dynamic URLs
  • Skip testing - meta tags are crucial for SEO

Migration Guide #

Troubleshooting #

Meta tags not showing up #

  • Ensure MetaTags component is placed in your +layout.svelte
  • Check that layoutMetaTags is returned from +layout.server.ts
  • Verify deepMerge is correctly combining layout and page meta tags
  • Use browser DevTools to inspect the <head> section

Tests failing for og:url #

  • Add url parameter to your page's load function: export const load = ({ url }) => {...}
  • Include url: url.href in the og object of pageMetaTags
  • Ensure the test expects the full URL including protocol and domain

Keywords not appearing on pages #

  • Confirm keywords is defined in +layout.server.ts
  • Check that deepMerge is being used in +layout.svelte
  • If a page defines pageMetaTags without keywords, they should inherit from layout

Technical information about this website