The Anqi CMS has always been committed to providing efficient and flexible solutions in content operations and search engine optimization.Structure data, especially JSON-LD, is an important means to enhance the visibility of website content in search engines.It can help search engines more accurately understand page content, thereby having the opportunity to display richer search results (i.e., rich media summaries), attracting more users to click.
autoCMS knows the importance of structured data, and has preset some default JSON-LD structured data for you in the system design. When your website publishes articles, products, or single pages, autoCMS usually automatically generates some basic JSON-LD code based on the page type and content.WebPage/ArticleThese codes will silently exist in the HTML code of the page, waiting to be crawled and parsed by search engines. You can view the source code of the page in the browser (usually right-click on the page -> “View Page Source” or “Inspect Element”), then search in the header or footer<script type="application/ld+json">Label, to confirm whether the system has generated these default data for you.
However, in the actual content operation, we often need to control these structured data more finely to meet specific business requirements, such as adding detailed information to the product page.ProductorOfferInformation, to specify more specific information for a particular articleArticleType, or add additional structured data such as authors, reviews, events, etc. At this time, the template customization feature provided by Anqi CMS comes into play.
The Anqi CMS allows you to customize or override the JSON-LD in the page through its powerful template engine. The core lies in using a special template tag: {% jsonLd %} ... {% endjsonLd %}.The role of this tag is to wrap your custom JSON-LD code snippet.When the content within this tag is parsed, AutoCMS will automatically merge it with the JSON-LD generated by the system by default.If the fields contained in your custom code conflict with the fields generated by default, your custom fields will override the default fields, thus achieving flexible customization.
The specific operation steps are usually as follows:
Firstly, you need to determine which page type to customize JSON-LD. This may include article detail pages (for example,)article/detail.html)、product detail page (e.g.,)product/detail.html)、single page (e.g.,)page/detail.html)even the homepage (e.g.,)index/index.html)。These template files are located in the template directory of your website.
Then, open the template file you want to modify. In the file<head>area (although it can also be recognized by search engines when placed in<body>it is still recommended to place<head>To ensure it is parsed as soon as possible), you can use{% jsonLd %}tags to embed your custom JSON-LD. For example, suppose you want to add more richArticleType data, including publisher, main entity link, publish date, and modify date, etc., you can write it like this:
{% jsonLd %}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "{{ archive.Title }}",
"image": [
"{{ archive.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": "{{ archive.Author|default:"安企CMS编辑团队" }}"
},
"publisher": {
"@type": "Organization",
"name": "{% system with name="SiteName" %}",
"logo": {
"@type": "ImageObject",
"url": "{% system with name="SiteLogo" %}"
}
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ archive.Link }}"
},
"description": "{{ archive.Description|truncatechars:150 }}"
}
</script>
{% endjsonLd %}
In this example, we use the template tags of the Anqi CMS to dynamically obtain page content.{{ archive.Title }}Used to obtain the article title,{{ archive.Logo }}Used to obtain the thumbnail,{{ stampToDate(...) }}Used to format the timestamp,{% system with name="SiteName" %}and{% system with name="SiteLogo" %}Then retrieve the website name and Logo. If the article does not set the author,{{ archive.Author|default:"安企CMS编辑团队" }}a default value will be provided to ensure the integrity of the data.
Please note that when writing custom JSON-LD, be sure to ensure that its syntax is correct and conforms to the schema.org specification.Any syntax error can cause the search engine to fail to parse, thereby losing the advantages brought by structured data.You can use the Rich Media Search Results Test tool provided by Google or the Structured Data Testing Tool to verify your code.
By this means, you can flexibly adjust and optimize structured data according to your business needs, for different page types, even for individual pages, to win a better performance for your website in search engines.This feature of Anqi CMS allows content operators to participate more deeply in the control of SEO details, truly realizing fine-grained operation.
Common Questions (FAQ)
How to confirm that the security CMS has automatically generated JSON-LD structured data?You can view the source code of any page in the browser by right-clicking the page and selecting "View Page Source" (or pressing
Ctrl+U/Command+Option+U), then searching in the opened source code page.<script type="application/ld+json">Label. If found, it means that the Safe CMS has generated the default JSON-LD data for you.Can I completely remove the JSON-LD generated by the default settings of Anqi CMS?The AutoCMS is designed to encourage optimization and expansion of default structured data rather than complete removal. If you need to completely override a default field,
{% jsonLd %}Provide your own field with the same name inside the tag. If you want a certain page to not display any structured data, you can try to override an empty JSON-LD object in the template, for example:{% jsonLd %}<script type="application/ld+json">{}</script>{% endjsonLd %}This is usually not recommended, because structured data is beneficial for SEO.What will happen if there are errors in my custom JSON-LD code?If your JSON-LD code contains syntax errors or does not conform to the schema.org specification, search engines may not be able to parse it correctly.This may cause your page to be unable to obtain rich media summaries, and may even report errors in Google Search Console.Strongly recommend using Google's rich media search results testing tool immediately after deploying custom JSON-LD code to verify its validity.