Dynamic JSON-LD generation in initial HTML for AEM Edge Delivery Services product detail pages

✨ This content is AI generated and could be inaccurate. Generative AI Terms

This article explains how to generate and include dynamic, product-specific JSON-LD in the initial HTML response for Product Detail Pages (PDPs) using Adobe Experience Manager Edge Delivery Services and Universal Editor.

Description description

Environment

Adobe Experience Manager (AEM) Edge Delivery Services (all versions)

Symptoms

  • Product Detail Pages (PDPs) use a shared product page template.
  • After the initial Edge Delivery Services (EDS) HTML response, client-side JavaScript resolves the product from the URL and fetches product data from external sources.
  • The frontend generates structured data schemas (Product, NutritionInformation, BreadcrumbList, AggregateRating, Review, etc.) and injects them into the DOM.
  • These schemas are visible in the rendered DOM but are not present in the initial HTML (i.e., not visible in “View Page Source” or via curl <PDP URL>), as they are generated after browser-side JavaScript execution.
  • Static JSON-LD authored via the AEM page-level json-ld field is included in the initial EDS HTML, but this field cannot generate dynamic, product-specific schema for each PDP URL.
  • The requirement is to have product-specific JSON-LD generated dynamically and included in the initial HTML response, without relying on client-side JavaScript, and supporting data from external sources.

No specific error codes or stack traces are present, but the absence of JSON-LD in the initial HTML is the core symptom.

Cause

Client-side JavaScript cannot inject structured data into the initial HTML response, which is required for SEO and external tools. Server-side data fetching and markup generation using BYOM and content overlays allow dynamic, product-specific JSON-LD to be included in the initial HTML before it is delivered to the browser.

Resolution resolution

Follow the steps below to resolve the issue.

  1. Understand the limitation of client-side rendering.

    • Client-side JavaScript cannot provide structured data in the initial HTML response, which is required for SEO and external validation tools.
  2. Use server-side data fetching and markup generation.

    • Implement a server-side solution to resolve the product from the requested URL and fetch product data from external sources before the HTML is generated.
  3. Leverage BYOM (Bring Your Own Markup) with content overlay.

    • Use the BYOM approach in Edge Delivery Services to allow custom server-side logic for dynamic routes.
    • Configure a dynamic route that extracts the product slug from the URL.
    • Fetch the required product data from external APIs during the server-side rendering phase.
    • Generate the JSON-LD schema using a templating engine (such as Mustache) and inject it into the <head> of the HTML document.
  4. Use Configuration Service and JSON2HTML.

    • Utilize the Configuration Service to manage API endpoints and credentials securely.
    • Use the JSON2HTML library with a Mustache template to transform fetched product data into the required JSON-LD format.
    • Example: Adobe JSON2HTML documentation
  5. Test and validate.

    • Deploy the solution to a development environment.
    • Validate that the JSON-LD is present in the initial HTML response by using “View Page Source” or curl <PDP URL>.
    • Ensure that the JSON-LD is product-specific and matches the data from external sources.
  6. Reference implementation.

recommendation-more-help
experience-cloud-kcs-help-kbarticles