Skip to content

SEO & Metadata (JSONB)

In Pyxis CMS, search engine optimization (SEO) data is managed through a single, flexible JSONB column. This approach prioritizes extensibility without the need for constant database schema changes.

Traditional CMS architectures often use separate columns for every meta tag (e.g., seo_title, seo_description). Pyxis CMS replaces this with a structured JSON object for several reasons:

  1. Schema Stability: Adding a new meta tag (like canonical_url or twitter:card) only requires a change in the Admin Panel UI, not a database migration.
  2. PostgreSQL Performance: Using the jsonb type ensures that data is stored in a binary format, allowing for efficient retrieval and indexing if needed.
  3. Headless Ready: The Next.js frontend receives a clean, nested object, making it easy to map directly to <meta> tags in the document head.

To make JSON data easy to work with in PHP, the Page model uses Attribute Casting:

protected $casts = [
'seo' => 'array',
];

In the admin panel, we utilize dot notation to map form fields directly to keys within the JSON object. This creates a seamless bridge between the UI and the database:

  • seo.title maps to the title key.
  • seo.description

A typical SEO entry in the database looks like this:

{
"title": "Welcome to Pyxis CMS",
"description": "The modern headless CMS built for developers.",
"og_image": "pages/seo/cover.jpg"
}