In today's digital marketing environment, the importance of Search Engine Optimization (SEO) is self-evident, and structured data is one of the key factors in improving a website's performance on search engine results pages (SERP).AnQiCMS as a system focusing on providing efficient content management solutions, its flexible customization and output of Json-LD structured data in templates provide powerful SEO optimization tools for website operators.
Structured data: The "language" of search engines
Json-LD (JavaScript Object Notation for Linked Data) is a lightweight data format that uses JSON syntax to represent entities and their relationships on web pages.For search engines, Json-LD is like a clear summary of the website's content, which can help them understand the page content more accurately, such as the page's theme, author, publication date, product price, review stars, and so on.Implementing JSON-LD correctly allows your content to be displayed in search results as 'rich snippets' (such as displaying article thumbnails, rating stars, or event dates), thereby significantly improving the visibility and click-through rate of your content.
AnQiCMS was designed with SEO-friendliness in mind from the beginning, providing a series of advanced SEO tools such as static URLs, keyword management, and Sitemap generation.On this basis, by using its powerful template engine, you can go further and accurately control the JSON-LD output of the page to meet more complex business needs and search engine optimization strategies.
Custom output mechanism of Json-LD in AnQiCMS
AnQiCMS knows the diversity of website content, and therefore provides high flexibility at the template level to manage structured data.The system may have already generated some basic structured data, but in order to adapt to the characteristics of different types of content such as articles, products, and events, you often need to customize more detailed and targeted Json-LD.
In AnQiCMS templates, you can use a special tag{% jsonLd %}...{% endjsonLd %}To implement custom output of Json-LD structured data.The design concept of this tag is: it allows you to write any JSON code that conforms to the Json-LD specification.It is more important that it does not simply replace the Json-LD output that AnQiCMS may already have, but will intelligently merge with the default data.This means that if the custom field conflicts with the default generated field, your custom data will have a higher priority and thus override the default value.This merging mechanism ensures that you can take advantage of the convenience provided by the system while also having complete control over the final output.
For example, a basic custom Json-LD output structure may look like this:
{% jsonLd %}
<script type="application/ld+json">
{
"author": "您的公司名称",
"image": [
"https://您的网站.com/默认图片.png"
]
}
</script>
{% endjsonLd %}
Dynamically output Json-LD data with template tags
It is not enough to statically output Json-LD to fully utilize its maximum effect.The true strength of Json-LD lies in its ability to dynamically capture specific content on a page and structure it.AnQiCMS rich template tag system makes this process very smooth.You can easily insert dynamic information such as article title, description, images, and publish time into the Json-LD code using template tags.
Here are some examples of how to combine AnQiCMS template tags to output Json-LD for common content types (such as article detail pages):
1. Article Json-LD example
In the article detail page template, you can build Json-LD like this:
{% with articleTitle = archive.Title %}
{% with articleDesc = archive.Description %}
{% with articleLink = archive.Link %}
{% with articleLogo = archive.Logo %}
{% with articleCreatedTime = stampToDate(archive.CreatedTime, "2006-01-02T15:04:05+08:00") %}
{% with articleUpdatedTime = stampToDate(archive.UpdatedTime, "2006-01-02T15:04:05+08:00") %}
{% with siteName = system.SiteName %}
{% with siteLogo = system.SiteLogo %}
{% jsonLd %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ articleLink }}"
},
"headline": "{{ articleTitle }}",
"image": [
"{{ articleLogo }}"
],
"datePublished": "{{ articleCreatedTime }}",
"dateModified": "{{ articleUpdatedTime }}",
"author": {
"@type": "Person",
"name": "(此处可动态获取作者名,例如:{% archiveDetail with name="author" %})"
},
"publisher": {
"@type": "Organization",
"name": "{{ siteName }}",
"logo": {
"@type": "ImageObject",
"url": "{{ siteLogo }}"
}
},
"description": "{{ articleDesc }}"
}
</script>
{% endjsonLd %}
{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}
In this example, we utilized AnQiCMS'sarchiveobject (used to get the details of the current article),systemobject (used to get the global settings of the website), and as well asstampToDateA filter to format time to match the time format required by Json-LD.{% archiveDetail with name="author" %}It can be used to obtain the author information from the custom fields of the article.
2. Product (Product) Json-LD example
For the product detail page, you can add more unique product information such as price, stock, reviews, etc:
`twig {% with productTitle = archive.Title %} {% with productDesc = archive.Description %} {% with productLink = archive.Link %} {% with productLogo = archive.Logo %} {% with productPrice = archive.Price %} {% with productStock = archive.Stock %} {% with siteName = system.SiteName %} {% with siteLogo = system.SiteLogo %}
{% Ld %}