Does the Json-LD custom tag support dynamically retrieving the website name and Logo from the `system` tag?

As an experienced website operations expert, I know the importance of search engine optimization (SEO) in the present day, and structured data, especially Json-LD, is undoubtedly the key tool to improve the understandability and search ranking visibility of website content. Today, we will delve into a common problem encountered by AnQiCMS users:Json-LD custom tag whether it supports dynamic acquisitionsystemThe website name and Logo in the tag?

Overview of JSON-LD support in AnQi CMS

Let's briefly review the role of Json-LD in the safety CMS.Json-LD is a lightweight data format that allows website administrators to describe page content in a standardized way to search engines, such as whether the website is an 'Organization', an 'Article', or a 'Product', and so on.This is crucial for search engines to understand the context of a page and generate rich media search results (Rich Snippets).

AnQi CMS, as a SEO-friendly content management system, naturally includes built-in support for Json-LD. Through its provided{% jsonLd %}...{% endjsonLd %}Custom tags, users can flexibly insert or modify structured data in templates.This flexibility is the foundation for us to explore dynamic information acquisition.The design concept of AnQi CMS is to allow content operators to have more freedom in controlling the front-end display, which means it usually provides mechanisms to link data between different tags.

systemTags: the dynamic source of the core information of the website

In the template system of AnQi CMS,systemTags play a core role, allowing us to conveniently access the global configuration information of the website. This information is usually configured in the "Global Function Settings" in the background, including but not limited to the website name (SiteName)、website logo(SiteLogo)、home page address(BaseUrl)etc.

For example, in our template, we can easily obtain the website name and logo by the following method:

{# 获取网站名称 #}
<span>网站名称:{% system with name="SiteName" %}</span>

{# 获取网站Logo并显示 #}
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />

The strength of these tags lies in their ability to dynamically extract the latest configuration from the background database without manually modifying the template code, which greatly enhances the efficiency of website maintenance.So, can we bring this dynamism into the structured data of Json-LD?

Dynamic Fusion: Json-LD Custom Tags &systemInformation联动

The good news is that the design philosophy of Anqi CMS fully considers this flexibility, the answer is affirmative!Json-LD custom tags fully support dynamic retrievalsystemThe website name and Logo in the tag.

The implementation principle lies in the template rendering process of Anqi CMS. When the system encounters{% jsonLd %}When labeling, the content will not be immediately treated as a pure JSON string, but will be parsed and replaced first as if it were other template content. This means that we can{% jsonLd %}Block internal uses the conventional template variable syntax output.{{ 变量名 }}To embed bysystemTags or other methods to obtain dynamic data.

In order to better organize code and avoid embedding complex tag calls directly in the Json-LD structure, we usually adopt a clearer practice method: first,systemLabel value retrieved and assigned to a temporary variable (using English){% set %}or{% with %}Label), and then embed these temporary variables into the Json-LD structure. This not only makes the code more readable and maintainable, but also conforms to good practices in front-end development.

实战演示:构建动态的Schema.org组织结构化数据

Now, let's take a specific example to demonstrate how to achieve this dynamic integration in the AnQi CMS.We want to add a Schema.org "Organization" structured data type to the homepage of the website, which includes the dynamic name and Logo of the website.

{# 首先,我们利用 system 标签获取动态的网站名称和Logo,并赋值给临时变量 #}
{% set siteName = system("SiteName") %}
{% set siteLogo = system("SiteLogo") %}
{% set baseUrl = system("BaseUrl") %}

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "{{ siteName }}", {# 这里动态嵌入网站名称 #}
  "url": "{{ baseUrl }}",
  "logo": "{{ siteLogo }}", {# 这里动态嵌入网站Logo地址 #}
  "sameAs": [
    {# 您可以在这里添加社交媒体链接等,同样可以动态获取或硬编码 #}
    "https://www.facebook.com/yourpage",
    "https://twitter.com/yourhandle"
  ],
  "contactPoint": {
    "@type": "ContactPoint",
    "telephone": "{% contact with name='Cellphone' %}", {# 动态获取联系电话 #}
    "contactType": "customer service"
  }
}
</script>
{% endjsonLd %}

在上面的代码中,我们清晰地展示了如何通过{% set %}tosystemthe tags you getSiteName/SiteLogoandBaseUrl存储为模板变量。随后,在{% jsonLd %}Block inside, we use it like a normal template variable, through{{ siteName }}and{{ siteLogo }}Embed dynamic information into the JSON structure of Json-LD.Even so, we also demonstrated how to dynamically obtain contact information, further demonstrating the template联动 ability of AnQi CMS.

Summary

Anqi CMS dynamically retrieves in Json-LD custom tagssystemThe function of website name and Logo in tags fully reflects its in-depth consideration in content management and SEO optimization.Through this flexible template mechanism, we can easily construct dynamic, accurate and easy-to-maintain structured data, laying a solid foundation for the website's performance in search engines.


Common Questions (FAQ)

  1. What information can I dynamically retrieve in Json-LD, besides the website name and Logo?Of course! You can dynamically obtain any data that any safe CMS template tag can provide using similar logic, such as through{% archiveDetail %}Label gets the title, author, publish date, image information of the current article, or through English{% categoryDetail %}Retrieve the relevant data for the category page. The key is to first use the corresponding tag to obtain the required data and assign it to the template variable, and then reference these variables within the block.{% jsonLd %}Block internal reference to these variables.

  2. {% jsonLd %}The label should be placed where in the template?Technically, you can use it at any position in the template{% jsonLd %}Tags, but for **SEO practices, structured data in Json-LD is usually recommended to be placed at the top of the page<head>tag, or immediately after<body>after the tags. The template of Anqi CMS