Tutorial: CGBlog + JSON-LD Markup

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Forum Members
Forum Members
Posts: 13
Joined: Fri Nov 10, 2017 10:25 am

Tutorial: CGBlog + JSON-LD Markup

Post by 1541 »

Just a quick hack:

For displaying JSON-LD data for Google SERPS,
https://developers.google.com/search/do ... es/article

I added following coding to the detail template of the CGBlog module:

Code: Select all

<__script__ type="application/ld+json">
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "{$entry->canonical}"
  "headline": "{$entry->title|escape}",
  "image": [
  {if $entry->fieldsbyname.image->type=='image'}
    {foreach from=$entry->fields item='field'}
        {if $field->type == 'image'}
          {if not $field@last}, {/if}
  "datePublished": "{$entry->postdate}",
  "dateModified": "{$entry->modified_date}",
  "author": {
    "@type": "Person",
    "name": "{$entry->author}"
  "publisher": {
  "@type": "Organization",
  "name": "{$entry->author}",
    "logo": {
    "@type": "imageObject",
    "url": "https://www.example.com/logo.png"
Use <__script__ ... > without underline, unlike above!

Have fun :)
New Member
New Member
Posts: 1
Joined: Thu Mar 14, 2019 9:23 am

Re: Tutorial: CGBlog + JSON-LD Markup

Post by ransen »

Thanks for this tutorial. I work with data JSON-LD now.

Return to “Tips and Tricks”