How to create an automated knowledge graph for your blog with PHP and JSON-LD.

by SkillAiNest

When someone searches for information today, they increasingly turn to AI models like ChatGPT, Perplexity, or Gemini instead of Google. But these models do not return a list of links. They synthesize the answer and cite the sources they trust most.

The question for anyone who runs a blog or content site is: How do you become one of those trusted sources? The answer lies in structured data, specifically JSON-LD knowledge graphs that help AI models understand not only what your content says, but how it connects to everything else you publish.

In this tutorial, you’ll create a PHP function that automatically generates a JSON-LD knowledge graph for each blog post on your site. There are no plugins, no external APIs, and just one function. It will detect entities in your content, map relationships between posts, and output a unified schema that can be parsed by both Google and AI models like ChatGPT as a coherent system.

Table of Contents

Why is this important now?

AI search engines are replacing blue links with synthesized answers. When someone asks ChatGPT a question, it doesn’t return a list of URLs. It prepares the answer by referring to its trusted sources.

According to AcuraCast’s research on AI search references81% of pages referenced by AI engines use schema markup with JSON-LD as the dominant format. Pages with a structured schema are 3 to 4 times more likely to be cited by ChatGPT or Perplexity than pages without.

Most JSON-LD tutorials teach you to paste statically. '; }

A visual representation of the @graph architecture that shows website, organization, person, webpage, and blog postings linked by @id references.

gave json_encode The flag matters. JSON_UNESCAPED_SLASHES Prevents URL escaping. JSON_UNESCAPED_UNICODE Keeps non-ASCII characters readable for multilingual content. Without them, a special character in a blog post title fetched from the database could silently break an entire JSON-LD block.

What does the output look like in production?

Here is the original JSON-LD generated by a real post. shinobis.coma blog about AI tools and UX design:

{
  "@context": "
  "@graph": (
    {
      "@type": "WebSite",
      "@id": "
      "name": "Designer in the Age of AI",
      "description": "AI tools and real workflows from a designer who builds with AI.",
      "url": "
      "inLanguage": "en",
      "publisher": { "@id": " }
    },
    {
      "@type": "Organization",
      "@id": ",
      "name": "Shinobis",
      "url": "
      "logo": { "@type": "ImageObject", "url": " }
    },
    {
      "@type": "Person",
      "@id": "
      "name": "Shinobis",
      "description": "UX/UI Designer with 10+ years in banking and fintech.",
      "url": "
      "jobTitle": "UX/UI Designer",
      "sameAs": (
        "
        "
      )
    },
    {
      "@type": "WebPage",
      "@id": "
      "url": "
      "name": "One Year with AI: Open Letter to Designers",
      "isPartOf": { "@id": " }
    },
    {
      "@type": "BlogPosting",
      "@id": "
      "headline": "One Year with AI: Open Letter to Designers",
      "description": "One year ago I started this journey. Today I write to all designers who are still doubting, fearing, or ignoring AI.",
      "abstract": "One year ago I started this journey. Today I write to all designers who are still doubting, fearing, or ignoring AI.",
      "url": "
      "datePublished": "2026-02-15T09:00:00-05:00",
      "dateModified": "2026-03-20T14:30:00-05:00",
      "inLanguage": "en",
      "wordCount": 1842,
      "author": {
        "@type": "Person",
        "@id": "
        "name": "Shinobis",
        "url": "
      },
      "publisher": {
        "@type": "Organization",
        "@id": ",
        "name": "Shinobis",
        "logo": { "@type": "ImageObject", "url": " }
      },
      "isPartOf": { "@id": " },
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "
      },
      "about": (
        { "@type": "Thing", "name": "Midjourney", "url": " },
        { "@type": "Thing", "name": "Prompt Engineering" }
      ),
      "mentions": (
        { "@type": "Thing", "name": "Claude", "url": " }
      ),
      "relatedLink": (
        "
        "
      ),
      "citation": (
        "
        "
      ),
      "keywords": ("Midjourney", "Prompt Engineering", "Claude"),
      "workTranslation": (
        {
          "@type": "CreativeWork",
          "@id": "
          "headline": "Un año con IA: carta abierta a los diseñadores",
          "url": "
          "inLanguage": "es"
        },
        {
          "@type": "CreativeWork",
          "@id": "
          "headline": "AIと一年:デザイナーへの公開書簡",
          "url": "
          "inLanguage": "ja"
        }
      )
    }
  )
}

Annotated JSON-LD output showing key features: constant @id, summary for LLMs, auto-detect entities, reference relationships, and work translation for multilingual authority

Compare this to the static version: a BlogPosting With title and author’s name. The difference is not cosmetic. There is a difference between it. “is an article” and “is a knowledge node associated with an author with verified profiles, published by an organization, linked by references to related articles, covering specific topics, and available in three languages.”

Testing your implementation

After deploying, verify on Google’s Rich Results Test. Paste the URL of any post and search your blog posting with all features.

For a deeper audit, copy

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

At Skillainest, we believe the future belongs to those who embrace AI, upgrade their skills, and stay ahead of the curve.

Get latest news

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

@2025 Skillainest.Designed and Developed by Pro