In today's highly competitive online environment, making your website content stand out in search engine results pages (SERP) is the key to attracting user clicks.The Json-LD structured data is an important tool to achieve this goal.By embedding Json-LD in the page, you can provide explicit information about the page content to search engines, giving you the opportunity to display it in a richer format (such as star ratings, product prices, article thumbnails, etc.) in search results. This is what we commonly refer to as 'rich media results'.

The AnQiCMS was designed with SEO (Search Engine Optimization) needs in mind from the very beginning, providing a comprehensive solution from content publishing to advanced SEO tools, aimed at helping users improve the visibility and ranking of their websites.Its flexible template mechanism and support for custom tags make it particularly convenient and efficient to integrate Json-LD structured data into web pages.

Understanding the fusion points of AnQi CMS and Json-LD

The system may automatically output some basic JSON-LD structured data when generating pages.By customizing Json-LD tags, you can check, improve, or even override these default outputs to achieve more precise and richer multimedia display results.

Basics of Json-LD: Core Elements and Common Types

  • @context: Specifies the vocabulary used by Json-LD, which is usuallyhttp://schema.org.
  • @type: Defined the type of entity you are describing, for exampleArticle(Article),Product(Product),Organization(Organization) orWebSite(Website).

Choose the appropriate one based on different page content@typeDescribe your entity and fill in the corresponding properties.The strength of Anqi CMS lies in its ability to help you easily embed the required dynamic data into Json-LD code.

In the AnQi CMS template, apply Json-LD

To embed Json-LD in the AnQi CMS page, we mainly use{% jsonLd %}This custom tag. This tag is usually placed in the HTML page.<head>Within this area, because it allows search engines to more quickly discover and understand structured data during crawling and rendering of the page.

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "您要描述的实体类型",
  "name": "实体名称",
  "url": "实体URL",
  // 其他属性...
}
</script>
{% endjsonLd %}

The following will demonstrate how to dynamically fill Json-LD data in several common scenarios in the security CMS.

Scenario one: Structured data of the article page (Article)

For blog posts or news pages, we can useArticletype to describe. This helps to display article titles, publication dates, authors, thumbnails, and other information in search results.

Assuming we want to embed in the article detail pageArticleof the Json-LD type:

{# 确保在文档详情页中才能正确获取archive数据 #}
{% archiveDetail currentArchive with name="Id" %} {# 确保archiveDetail标签已获取当前文档数据 #}
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "{% tdk with name="Title" %}", {# 文章标题,使用TDK标签获取 #}
  "image": [
    "{% archiveDetail with name="Logo" %}" {# 文章封面图 #}
  ],
  "datePublished": "{{ stampToDate(archive.CreatedTime, "2006-01-02T15:04:05-07:00") }}", {# 发布日期,注意时间格式 #}
  "dateModified": "{{ stampToDate(archive.UpdatedTime, "2006-01-02T15:04:05-07:00") }}", {# 修改日期 #}
  "author": {
    "@type": "Person",
    "name": "安企CMS小编" {# 示例作者名,可替换为动态获取 #}
  },
  "publisher": {
    "@type": "Organization",
    "name": "{% system with name="SiteName" %}", {# 网站名称 #}
    "logo": {
      "@type": "ImageObject",
      "url": "{% system with name="SiteLogo" %}" {# 网站Logo #}
    }
  },
  "description": "{% tdk with name="Description" %}", {# 文章描述,使用TDK标签获取 #}
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "{% archiveDetail with name="Link" %}" {# 文章链接 #}
  }
}
</script>
{% endjsonLd %}

Please note,{% archiveDetail with name="Id" %}This line is a placeholder to ensure that the subsequentarchiveThe variable is available. In the actual template, if the page is already the document detail page,archivethe object can usually be accessed directly.stampToDateThe filter is used to format timestamps into the ISO 8601 format required by Json-LD,|safeThe filter is used to ensure that the output HTML or JSON content is not escaped.

Scenario two: Structured data of the product page (Product)

For the product display page,ProductThe type can provide product name, image, price, review information, which is especially important for e-commerce or product display websites.The "Flexible Content Model" feature of Anqi CMS plays a huge role here, allowing you to customize various properties of products.

”`twig {# Assuming in the product detail page, the archive variable represents the current product #} {% archiveDetail currentProduct with name=“Id” %} {# Ensure that the archiveDetail tag has obtained the data of the current document #}