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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Nesting search engine meta-tag titles?


Go to End


3 Posts   1842 Views

Avatar
ThereBeDragonsHere

Community Member, 8 Posts

15 August 2010 at 3:39pm

Hi folks,

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?

Avatar
Bambii7

Community Member, 254 Posts

17 August 2010 at 11:10am

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 %> &raquo; $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 %> &raquo; 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 %> &raquo; <% control Parent %><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %><% end_control %></title>

That should pull the parents title or meta tag.

Avatar
ThereBeDragonsHere

Community Member, 8 Posts

17 August 2010 at 11:27pm

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?