Skip to content

Single CMS Page

About

The page(id:) query retrieves a single CMS (Content Management System) page by its IRI-style ID. Use this query to:

  • Render a specific CMS page (e.g. About Us, Privacy Policy) in the storefront
  • Retrieve the full HTML content of a page for display
  • Access SEO metadata (meta title, description, keywords) for a specific page
  • Fetch locale-specific translation data for a page
  • Build dynamic page routes using urlKey
  • Validate whether a page exists before rendering

This query returns a single page with its active locale translation. Use the pages query to list all available pages.

Arguments

ArgumentTypeRequiredDescription
idID!✅ YesIRI-style identifier of the page (e.g. /api/shop/pages/1).

Possible Returns

Page Fields

FieldTypeDescription
idID!IRI-style unique identifier (e.g. /api/shop/pages/1).
_idInt!Numeric database ID.
layoutStringPage layout template name (e.g. default).
createdAtDateTime!Timestamp when the page was created.
updatedAtDateTime!Timestamp when the page was last updated.
translationPageTranslationActive locale translation for this page.

PageTranslation Fields

FieldTypeDescription
idID!IRI-style ID of the translation record.
_idInt!Numeric translation record ID.
pageTitleString!Display title of the CMS page.
urlKeyString!URL slug used to access the page (e.g. about-us).
htmlContentStringFull HTML body content of the page.
metaTitleStringSEO meta title tag.
metaDescriptionStringSEO meta description tag.
metaKeywordsStringSEO meta keywords.
localeString!Locale code for this translation (e.g. en, fr).

Use Cases

1. Render a CMS Page

Fetch a specific page by ID and render its htmlContent on a dedicated page route in the storefront.

2. SEO Head Tags

Use metaTitle, metaDescription, and metaKeywords from the translation to populate <meta> tags dynamically.

3. Page Validation

Query a page before rendering to check whether it exists; handle null responses with a 404 page.

4. Multi-language Content

Use the locale field in translation to display locale-aware page content in multilingual storefronts.

5. Dynamic Page Routing

Use urlKey to implement client-side routing so users access pages via human-readable URLs (e.g. /about-us).

Best Practices

  1. Use the IRI format — Always pass the full IRI string (e.g. /api/shop/pages/1) as the id argument
  2. Handle null gracefully — If page returns null, show a 404 response to the user
  3. Sanitize htmlContent — Always sanitize the htmlContent field before rendering to prevent XSS vulnerabilities
  4. Cache individual pages — Cache page responses keyed by ID; invalidate the cache when content is updated
  5. Use urlKey for routing — Build page URLs from urlKey for SEO-friendly, human-readable links
  6. Fetch only needed fields — Omit htmlContent when only metadata (title, URL) is needed to reduce response size

Released under the MIT License.