As an experienced website operation expert, I fully understand the importance of website details for user experience and Search Engine Optimization (SEO).Crumbs navigation is such a detail that should not be ignored. It can not only clearly show the user's position in the website and provide a convenient return path, but also effectively improve the internal link structure of the website, which is very beneficial for SEO.However, the default "Home" link text may sometimes not fully fit your unique brand tone or multilingual needs.
Today, let's delve into how to easily customize the display text of the home link in the breadcrumb navigation in AnQiCMS, an efficient and customizable enterprise-level content management system.AnQiCMS with its concise and efficient Go language architecture and powerful template system provides great flexibility for content operations, making these personalized needs accessible.
Understanding the AnQiCMS breadcrumb navigation mechanism
In AnQiCMS, the website's page structure and content display are inseparable from its flexible template engine.Breadcrumbs navigation is usually generated through a dedicated template tag, which greatly simplifies the development and maintenance work..htmlas the template file suffix, and stored uniformly in the/templateThe directory. This means that all page elements, including breadcrumbs, can be customized by editing these template files.
AnQiCMS provides a namedbreadcrumbThe template tag, specifically used for dynamically generating breadcrumb navigation.This label can intelligently build a complete navigation chain from the home page to the current page based on the URL path of the current page.Its strength lies in its ability to automatically recognize the hierarchical relationship of pages, and it also allows us to adjust the display style of some links by simple parameter settings.
Locate and modify the breadcrumb navigation code.
To customize the display text of the home page link, you first need to find the website template that calls itbreadcrumbLabel code snippet. According to the AnQiCMS template conventions, breadcrumb navigation is usually placed in the public code snippet directorypartial/in a file, for examplepartial/breadcrumb.html, or directly included inbash.html(Typically the global header or footer template) or a specific page template (such asindex/index.html/{模型table}/detail.htmletc.) in it.
Find the following similarbreadcrumbtag code:
{% breadcrumb crumbs %}
<ul>
{% for item in crumbs %}
<li><a href="{{item.Link}}">{{item.Name}}</a></li>
{% endfor %}
</ul>
{% endbreadcrumb %}
This code is the basic structure of the breadcrumb navigation.{% breadcrumb crumbs %}The label will generate an array object namedcrumbs, which includes every step (link) on the navigation path. Then,{% for item in crumbs %}to iterate over this array,{{item.Link}}output the link address,{{item.Name}}output the display text of the link.
Customize the display text of the home page link
AnQiCMSbreadcrumbTags provide aindexParameter, used specifically for customizing the display text of the home page link.By default, if you do not set this parameter, the text on the homepage will display as “Home”.But we can easily achieve personalization by modifying the value of this parameter.
Imagine that your website theme is about an art gallery, you may want to display "Home" as "Gallery HomepageAnQiCMS makes everything simple.
You just need tobreadcrumbtag.indexParameters, and assign the text value you want.
Example: Change 'Home' to 'My Homepage'
{% breadcrumb crumbs with index="我的主页" %}
<ul>
{% for item in crumbs %}
<li><a href="{{item.Link}}">{{item.Name}}</a></li>
{% endfor %}
</ul>
{% endbreadcrumb %}
By this simple modification, the first link in the breadcrumb navigation of your website will no longer be “Home”, but your customized “My Homepage”.This method is not only intuitive but also does not require modifying complex logic code, fully demonstrating the convenience of AnQiCMS in the customization aspect.
Further optimization: Control the display of the current page title
In addition to customizing the homepage text,breadcrumbthe tag also provides,titleParameter, used to control the display method of the current page title in the breadcrumb navigation. By default,title=trueIt will display the complete title of the current page. You can also adjust it as needed:
title=false:It will not display the title of the current page. This may be more concise in some designs.title="自定义文本":Set the current page title to be displayed as the specified text.
For example, if you do not want to display the current page title at the end of the breadcrumbs, you can set it like this:
{% breadcrumb crumbs with index="我的主页" title=false %}
<ul>
{% for item in crumbs %}
<li><a href="{{item.Link}}">{{item.Name}}</a></li>
{% endfor %}
</ul>
{% endbreadcrumb %}
So, the breadcrumb navigation will be displayed in the form of “My Homepage > Category Name”, without including the specific title of the current article or product page.
Summary
AnQiCMS provides powerful content management and flexible customization capabilities for website operators. By navigating through the breadcrumb navigation,breadcrumbTagsindexandtitleThe parameter is simply configured, allowing us not only to easily customize the display text of the home page link but also to flexibly adjust the display method of the current page title according to actual needs.This not only helps shape a unified brand image and improve user experience, but also lays a solid foundation for the SEO optimization of the website.Remember to back up your template file before making any template modifications, and verify the changes in the test environment to ensure the stable operation of the website.
Common Questions (FAQ)
问:我能否完全移除面包屑导航中的“首页”链接? Answer:可以的。您可以通过将
index参数设置为空字符串来实现,例如{% breadcrumb crumbs with index="" %}.However, it is usually not recommended to completely remove the home page link to maintain the integrity of navigation and user experience, as it provides a clear starting point.item.NameIs it empty or a specific value, and then decide whether to render this item.Question: If I want the home page link text to change dynamically according to the language environment of the website, how should I implement it? Answer:AnQiCMS supports multi-language functionality, you can use it in templates
trtags to translate text. First, you need to set up thelocalesThe language package file is configured under the directory. Then,indexSet the value of the parameter to a translation key, for example:{% breadcrumb crumbs with index=(tr "homepage.text") %}So, when the website switches language, the text of the homepage links will automatically load the translation corresponding to the language.问:Where can I find the specific file in my website template that is used for setting up the breadcrumb navigation? Answer:According to AnQiCMS template conventions, common code snippets like breadcrumbs are usually stored in
/template/您的模板目录/partial/folder, and common filenames might bebreadcrumb.html/header.htmlorfooter.html. You can also search for them in the template files{% breadcrumbKeywords can be used to quickly locate related code. It is also usually possible to directly edit these template files in the "Template Design" feature in the background.