Skip to main content
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
I was wondering if SilverStripe has the functionality of automatically nesting search engine meta-tag titles. For instance, the name of my website is "The Lusitania Resource," so I'd like my subsequent pages to automatically have "The Lusitania Resource" appended to the search engine titles (e.g. "Mixed Claims Commission « The Lusitania Resource").
Or does this functionality not exist and I would have to do all of this by hand?
There is a function on SiteTree.php line 1225 called MetaTags()
You should be able to overwrite this in mysite/code/Page.php to control the meta tag behavior.
But I think you just want to edit the page Titles yeah?
<title><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %> » $SiteConfig.Title</title>
If you just wanted The Lusitania Resource appended to every title you could make it you site Title or hard code it in
<title><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %> » The Lusitania Resource</title>
Or if you wanted something more dynamic you could control the parent in the title output kind of like bread crumbs.
<title><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %> » <% control Parent %><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %><% end_control %></title>
That should pull the parents title or meta tag.
Hey that's pretty neat with the breadcrumb-like layout. It looks great with the nested pages, looking like:
XXXXXX » YYYYYY » The Lusitania Resource
But now I've run into a problem with the top-level pages where they look like
YYYYYY » » The Lusitania Resource
Where the » is appearing twice. Is there a way around this so that » appears only for the number of times needed?