Define custom page titles and meta descriptions without the aid of using additional addons and plugins. Use the below method to set custom SEO-friendly page titles and meta descriptions on any page type or node.
Locate your page_container in the Xenforo ACP, replace the code for rendering the existing meta title and description with the following.
Node pages
Replacing the node ID with the ID of the page your overriding the metadata for. You can find it by viewing the page source code under data-container-key="node-10". If you do not define a node ID, Xenforo will use the fallback option that is the traditional Xenforo title and description.
If you are overriding thread titles and descriptions, use this instead.
Thread Pages
And lastly, if you wish to override the titles and descriptions for the member account functions and pages. Use the following (replace "account_details" with the template ID).
Accounts & global page templates
If you're planning on overriding a number of page titles and meta descriptions. I recommend creating a fresh template file to house all of the custom metadata and call in the template file (replacing any existing page titles and descriptions) with the new template file. Something like this
Locate your page_container in the Xenforo ACP, replace the code for rendering the existing meta title and description with the following.
Node pages
Code:
<!-- page title -->
<xf:if is="$containerKey == 'node-10' ">
<title>Node custom page title goes here</title>
<xf:else />
<title><xf:title formatter="%s | %s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>
</xf:if>
<!-- meta description -->
<xf:if is="$containerKey == 'node-10' ">
<meta name="description" content="Node custom meta description goes here"/>
<xf:else />
<meta name="description" content="{$description}"/>
</xf:if>
Replacing the node ID with the ID of the page your overriding the metadata for. You can find it by viewing the page source code under data-container-key="node-10". If you do not define a node ID, Xenforo will use the fallback option that is the traditional Xenforo title and description.
If you are overriding thread titles and descriptions, use this instead.
Thread Pages
Code:
<!-- page title -->
<xf:if is="$contentKey == 'thread-45' ">
<title>Thread custom page title goes here</title>
<xf:else />
<title><xf:title formatter="%s | %s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>
</xf:if>
<!-- meta description -->
<xf:if is="$contentKey == 'thread-45' ">
<meta name="description" content="Thread custom meta description goes here"/>
<xf:else />
<meta name="description" content="{$description}"/>
</xf:if>
And lastly, if you wish to override the titles and descriptions for the member account functions and pages. Use the following (replace "account_details" with the template ID).
Accounts & global page templates
Code:
<!-- page title -->
<xf:if is="$template == 'account_details' ">
<title>page template custom page title goes here</title>
<xf:else />
<title><xf:title formatter="%s | %s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>
</xf:if>
<!-- meta description -->
<xf:if is="$template == 'account_details' ">
<meta name="description" content="page template custom meta description goes here"/>
<xf:else />
<meta name="description" content="{$description}"/>
</xf:if>
If you're planning on overriding a number of page titles and meta descriptions. I recommend creating a fresh template file to house all of the custom metadata and call in the template file (replacing any existing page titles and descriptions) with the new template file. Something like this
Code:
<xf:include template="seo_data" />