As a website operator who is well-versed in the operation of AnQiCMS, I know that the accuracy and efficiency of obtaining the current page content are crucial for the daily management and optimization of the website.AnQiCMS provides intuitive and powerful template tags, allowing us to easily extract the required document title, specific content, and standard link of the currently loaded page.This not only helps us with fine control over the front-end display, but also provides a solid foundation for SEO optimization.

Get the document title of the current page

The document title of the current page usually has two levels of meaning: one is HTML<title>Label displayed in the page title for search engines and browser users, which is crucial for SEO; it is also the document or article title used as the main identifier in the main content of the page.

针对HTML的<title>标签,AnQiCMS提供了tdk标签,我们可以通过{% tdk with name="Title" %}to dynamically obtain the current page title.This label will automatically generate the most suitable title according to the type of the current page (document, category, single page, etc.).siteName=true参数自动附加网站名称,通过sep参数自定义分隔符,以及showParent=trueParameters are used to display the title of the parent category, all of which are automatically adjusted according to the backend configuration.

When it is necessary to display the specific title of a document or article in the content area of the page, we can use a detailed label of a specific content type. For example, if the current page is an article or product detail page,archiveDetailTags, through{% archiveDetail with name="Title" %}English translation: It can be obtained by simply doing so. Similarly, for a single-page, we can use{% pageDetail with name="Title" %}English translation: For category pages, use{% categoryDetail with name="Title" %}English translation: For tag pages, use{% tagDetail with name="Title" %}These tags will default to fetching the title of the current page, single page, category, or tag if no ID or token is specified.

This is a brief example of obtaining the page title:

{# 获取HTML头部标题,并附加网站名称 #}
<title>{% tdk with name="Title" siteName=true %}</title>

{# 在页面主体内容中显示文章标题 #}
<h1>{% archiveDetail with name="Title" %}</h1>

Extract the specific content of the current page

Retrieve the main content of the current page is the core requirement for building dynamic web pages. The detail tag of AnQiCMS can accurately extract detailed information of various types of content.

For articles or product detail pages, we usearchiveDetailTags, through{% archiveDetail with name="Content" %}It can be used to obtain the full content of the document.This tag is very flexible when outputting content.|safeFilter, such as{{ archiveContent|safe }}. In addition, if the content contains images, we can also utilizelazy="data-src"Implement lazy loading of images to enhance page performance. When the Markdown editor is enabled on the backend, the content is automatically converted to HTML; if manual control over the conversion behavior is required, you can userender=trueorrender=falseParameter.

Similarly, if the current page is a single page, we can use{% pageDetail with name="Content" %}to get its content; for category pages, use{% categoryDetail with name="Content" %}English translation: For tag pages, use{% tagDetail with name="Content" %}. These tags also support|safeFilter and Markdown rendering control.

Here is an example of retrieving page content:

{# 获取文章主体内容,并确保HTML正确渲染 #}
<div>
    {%- archiveDetail articleContent with name="Content" lazy="data-src" render=true %}
    {{articleContent|safe}}
</div>

Get the link address of the current page

当前页面的链接地址同样是网站导航和SEO策略中不可或缺的一部分。AnQiCMS提供了多种方式来获取当前页面的标准URL。

The most direct way is to use specific content type detail tags. For example, for articles or product detail pages,{% archiveDetail with name="Link" %}Get the absolute or relative link on the website. Similarly, for single pages, use{% pageDetail with name="Link" %}; Category pages use{% categoryDetail with name="Link" %}; Tag pages use{% tagDetail with name="Link" %}These links are automatically generated based on the pseudo-static rules and content structure of the current page.

Moreover, for SEO, setting up canonical links (Canonical URL) is crucial, as it tells search engines the preferred version of the current page, avoiding content duplication issues. AnQiCMS throughtdkTags provide this feature, we can use{% tdk with name="CanonicalUrl" %}To get the current page's specification link. In the template, we usually judge whether this specification link exists, and if it exists, place it in the HTML's<head>areas.

The following is an example of obtaining a page link:

{# 获取文章的URL,可用于导航或分享按钮 #}
<a href="{% archiveDetail with name="Link" %}">阅读更多</a>

{# 在页面头部设置规范链接 #}
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}

Through these flexible and intelligent template tags, AnQiCMS enables website operators to efficiently manage and present content, making it easy to optimize page titles for improved search rankings, accurately control content display for enhanced user experience, or ensure the规范性 of page links to maintain website health.Mastering the use of these tags is the key to unleashing the potential of AnQiCMS content management.

Frequently Asked Questions

The detail tags of AnQiCMS (such as)archiveDetail/pageDetail/categoryDetail/tagDetail) when not explicitly specifiedidortokenWhen the parameter is set, it will automatically recognize the content type of the current page being displayed and extract the corresponding fields of the content.The system intelligently determines the core entity of the current page (such as which article, which category, which single page, or which tab page) through URL path, routing rules, and internal context information, thereby automatically obtaining its associated data.

You can specify explicitly in the detail tagidortokenParameters to retrieve data from non-current pages. For example, if you want to display the title of another specific article on the article detail page, you can use{% archiveDetail with name="Title" id="123" %}where,123Is the ID of the target article. In this way, you can call any specified content type of data on any page, achieving more complex page layout and content aggregation.

tdkTags are used to retrieve metadata related to the entire page, such as HTML<title>/<meta name="keywords">/<meta name="description">and<link rel="canonical">. This information is for the entire page rather than a specific item within the page.archiveDetail/pageDetailTags such as auto focus on obtaining the page contentcore content entities(For example, an article, a product) detailed fields of itself, such as its title, main content, and its own link. In practical applications, they work together:tdkTags are usually used in the HTML header, affecting search engine inclusion and browser display; while content detail tags are used in the main body of the page, used to display the specific information that the user is browsing.