As an experienced website operations expert, I am well aware of the importance of structured data for a website's performance in search engines.Json-LD as the mainstream method for implementing structured data, can help search engines better understand the content of the website, thereby improving the display opportunities of the website in search results, such as obtaining rich search results (Rich Snippets).Organization(Organization) andWebSiteJson-LD data of (website) type, allowing search engines to understand your website at a glance.
Why pay attention toOrganizationandWebSiteJson-LD of type?
Among the many types defined in Schema.org,OrganizationandWebSitethey are the two most basic and core types on the website.
OrganizationTypeMeant to describe the entity represented by your website, whether it is a company, organization, or personal brand.It typically includes name, official website URL, Logo, contact information, and social media links.This helps search engines understand your brand identity and display more rich information in places like knowledge graphs.WebSiteTypeIt describes the website itself. It usually includes the website name, URL, and a very importantpotentialActionProperties, used to define the on-site search function. This allows users to perform on-site search directly in the Google search results, greatly enhancing the user experience.
AnQiCMS was designed with the general needs of website operations in mind from the very beginning, therefore, many of the settings in the backend naturally correspond to Json-LD in EnglishOrganizationandWebSiteThe required key information.
The 'Treasure' of AnQiCMS Back-end: Information Spring
The AnQiCMS backend is an excellent starting point for providing Json-LD data streams. We can find the required information in the following core settings areas:
Global Function Settings (
help-setting-system.md):- Website Name (SiteName):This is the formal name of your organization or website, which directly corresponds to the
nameproperties. - Website Address (BaseUrl):The root URL of the website, corresponding to
urlproperties. - Website Logo (SiteLogo):The visual identity of the brand, corresponding to
logoproperties. - Custom parameters:If you have a link to your social media (such as Facebook, Twitter, LinkedIn, etc.), although AnQiCMS does not have a special social media field, we can use its flexible "custom parameter" function to add these links in the "Global Function Settings", for example, the parameter name is
FacebookUrl, The parameter value is the corresponding social media homepage link. These will be used forsameAsproperties.
- Website Name (SiteName):This is the formal name of your organization or website, which directly corresponds to the
Contact Information Settings (
help-setting-contact.md):- Contact (UserName), Phone Number (Cellphone), Address (Address), Email (Email):This information is
Organizationin the type.contactPoint(Contact point) is a key component.
- Contact (UserName), Phone Number (Cellphone), Address (Address), Email (Email):This information is
Home page TDK settings (
help-setting-tdk.md):- Home Title (Title), Home Keywords (Keywords), Home Description (Description):Although it is not used directly
OrganizationorWebSite的核心属性,但 EnglishDescription可以作为 EnglishWebSite的补充描述,而 EnglishTitleandKeywords则对整体SEO至关重要。 English
- Home Title (Title), Home Keywords (Keywords), Home Description (Description):Although it is not used directly
核心操作:利用 EnglishjsonLd标签“组装”结构化数据 English
AnQiCMS provides a very convenientjsonLdtags (tag-jsonLd.md
This provides us with great flexibility, allowing us to<head>area (usuallytemplate/您的模板名/partial/header.htmlortemplate/您的模板名/bash.html)add at the site level uniOrganizationandWebSiteJson-LD.
Now, let's see how to dynamically inject the above background information into Json-LD using template tags:
{% jsonLd %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"name": "{% system with name='SiteName' %}",
"url": "{% system with name='BaseUrl' %}",
"logo": "{% system with name='SiteLogo' %}",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "{% contact with name='Cellphone' %}",
"contactType": "Customer Service",
"email": "{% contact with name='Email' %}"
// 更多联系方式可以根据后台自定义字段添加
},
"sameAs": [
// 假设您在全局设置中创建了自定义参数 FacebookUrl, TwitterUrl, LinkedinUrl
"{% system with name='FacebookUrl' %}",
"{% system with name='TwitterUrl' %}",
"{% system with name='LinkedinUrl' %}"
// 如果联系方式设置里有社交媒体字段,也可以直接使用contact标签
// "{% contact with name='Facebook' %}",
// "{% contact with name='Twitter' %}",
// "{% contact with name='Linkedin' %}"
]
},
{
"@type": "WebSite",
"url": "{% system with name='BaseUrl' %}",
"name": "{% system with name='SiteName' %}",
"description": "{% tdk with name='Description' %}", // 使用首页描述作为网站描述
"potentialAction": {
"@type": "SearchAction",
"target": "{% system with name='BaseUrl' %}/search?q={search_term_string}", // 假设您的搜索页路径为 /search
"queryInput": "required name=search_term_string"
}
}
]
}
</script>
{% endjsonLd %}
In this code block:
- We used
{% system with name='...' %}Label to retrieve website name, base URL, and Logo. {% contact with name='...' %}Label is used to extract contact information and email, to constructcontactPoint.- Pass
{% system with name='FacebookUrl' %}Parameters such as auto, we can flexibly add social media links tosameAsThe array contains. Please make sure you have added these custom parameters in the "Global Feature Settings" and filled in the correct social media links. {% tdk with name='Description' %}The tag then gets the description of the website homepage,WebSiteType supplement information.potentialActionpoints to the AnQiCMS site search path, usually/searchwith,qParameter.
Place this code in the website template's<head>Label inside, AnQiCMS will dynamically extract the latest data from the background and generate the corresponding Json-LD structured data each time a page is rendered.This way, you don't need to touch complex code, just maintain the background information, and you can ensure that the structured data of the website is always up-to-date and accurate.
This method is not only extremely