About displaying selected topics and duplicate meta titles

Permalink
Here's the situation: I built a site that depends on sorting to drive people to certain kinds of features. This page shows all their projects and the available topics at the bottom:

http://newspaces.com/our-work/remodeling-projects...

I have it set up so that when you select, say, "white kitchens" from the choices at the bottom, the H1 page title changes to that selection as it displays the correct projects for that selection. The URL is showing the selection as well. HOWEVER, since it's really the same page, the meta title remains the same. That means I now have 30+ duplicate meta titles. Oops. Google issue.

When you make a selection, is there any way to change the meta title & description the same way I've changed the page title? If not, is there another way to solve this? Maybe something I've missed?

Thanks for the help.

bjalexander
 
bjalexander replied on at Permalink Reply
bjalexander
Thought I would post my solution in case someone else hits this and wonders what they can do.

Since the page I'm talking about displays a bunch of pages from the site as projects - pages which are already crawled and have unique headers, etc. - I don't really need it for Google Analytics. So rather than risk penalties for duplicate metas, I simply blocked that whole section in robots.txt. No more duplicates. While I would have loved the illusion of a fatter site, I could not see a way to make it work.
omars786 replied on at Permalink Reply
omars786
I had a similar problem on our site, wanting to make full use of the topic feature on the page lists, it was generating a whole lot of duplicate meta titles and so on.. I managed to find a solution that solved it.. its maybe a little messy but it works.

I was helped by the following posts:
https://www.concrete5.org/community/forums/customizing_c5/display-a-...
https://www.concrete5.org/community/forums/customizing_c5/override-h...

Method for 5.8:


1.
If you have 'over-ride cache' enabled in system - disable it until you get everything working.
Over-ride header_required.php by copying it from concrete/elements to application/elements

2.
copy it and rename it to header_require_something.php (so now you have 2 files in application/elements)

3. For header_required.php in application/elements you want it to work on every page apart from the page you have the topic list filter. I did this using an if statement:
defined('C5_EXECUTE') or die("Access Denied.");
$c = Page::getCurrentPage();
if ($c->getCollectionName() != 'something'){
// insert the if statement above and the closing bracket below - remaining code inside..
}

This prevents 2 headers from loading on the page, which would give multiple metadata..

4. Put a 'Page Title Block' on the page where you have this filterable page list. Create a template for this block (put it in application/blocks/page_title/templates) so it makes use of the current topic and requests the new header_required_somthing.php. An example template:
<?php
defined('C5_EXECUTE') or die("Access Denied.");
if (isset($currentTopic) && is_object($currentTopic)) {
$treeName = $currentTopic->getTreeObject();
if ($treeName->topicTreeName  == 'Topic Tree Name you are using'){
$title = t('%s', $currentTopic->getTreeNodeDisplayName());
$title = ucfirst($title);
//here its requesting that new header you created, write your custom metadata
 Loader::element('header_required_something', 
            array(
            'pageTitle' => $title.'can write here', 
            'pageDescription' => 'and here'.$title,
            ));
   }
if (isset($title)) {

Then assign the template to the title block, this is what's going to trigger the new header info.. If you remove it the page will not work properly as it won't have the header.

I hope this helps someone, I'm definitely not a pro and perhaps there is a better way to do this!