Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Nesting search engine meta-tag titles?

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

Page: 1
Go to End
Author Topic: 1148 Views
  • ThereBeDragonsHere
    Avatar
    Community Member
    8 Posts

    Nesting search engine meta-tag titles? Link to this post

    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?

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Nesting search engine meta-tag titles? Link to this post

    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.

  • ThereBeDragonsHere
    Avatar
    Community Member
    8 Posts

    Re: Nesting search engine meta-tag titles? Link to this post

    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?

    1148 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.