When building a website with Empire CMS, many administrators encounter the problem of custom title modification. The default title format in Empire CMS may not meet all users' needs, so how to modify the website title becomes a common challenge. This article provides two common code examples to help you solve the Empire CMS title modification problem and customize titles according to your needs.
First, log into the Empire CMS backend management system, go to "Website Settings" and find the "Basic Settings" section, where you will find the "Website Name" option. By default, the website title format is "{$webname} - {$description}". If you want to customize the title, you can modify it through code.
Here is a code example to modify the title based on category ID:
{if $article.Category.Id==1}<title>Home - {$webname}</title>{/if}
In this example, the title is set based on the current page's category ID. When the category ID is 1, it shows "Home - {$webname}". This way, you can set different titles for different pages.
Another common method is to set the title based on the page name. With the code below, you can dynamically generate titles based on different page names.
{assign var="currentPage" value=$arctitle}
Next, modify the title based on the page name:
{if $currentPage eq 'Home'}<title>Website Home - {$webname}</title>{elseif $currentPage eq 'About Us'}<title>About Us - {$webname}</title>{elseif $currentPage eq 'Product Center'}<title>Product Center - {$webname}</title>{else}<title>Untitled Page - {$webname}</title>{/if}
With this approach, you can ensure that each page's title is dynamically adjusted based on the page content, improving both user experience and SEO performance.
The two methods introduced above can help you flexibly modify the title of your Empire CMS website to meet different page needs. Whether modifying based on category ID or page name, you can easily set personalized titles for each page, thereby improving the SEO performance of your website.