Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3

Author Topic: home,archive,sitemap,contact risk a duplicate content !!  (Read 15378 times)

maxou

  • Jr. Member
  • **
  • Karma: 5
  • Posts: 81
  • Bug's Finder
home,archive,sitemap,contact risk a duplicate content !!
« on: April 22, 2008, 12:56:28 PM »

I noticed that Archives, Sitemap, Contact and the Home had the same meta name="description and meta name="keywords and worse the same <title> !  :o

It's not a good solution and you risk a duplicate-content !
Why ? because you have the same title and description on 4 pages with a different contents.

Solution : Get a unique meta description, title and meta keyword (meta keyword is not very important but it's cosmetic) for Archives, Sitemap, Contact and Home.

Home title and meta description is very easy to configure in the Admin but for Archives, Sitemap and Contact is more difficult.
I tried to modify snews.php, function title() to get a unique title, meta description and keyword for Archives, Sitemap and Contact, for example
Code: [Select]
echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta : s('archive')).'" />'; but I didn't make a success ...  :-\

I wait your answers. ;)
Logged
Work on XAMPP.

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 163
    • domdelimar.com
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #1 on: April 22, 2008, 01:45:21 PM »

Hi maxou,
Way back I was also concerned about the same title issue, although didn't give much thought to the same description and keywords issue you mention. I did however accomplish to have different page titles...

So here's how I accomplished that on one of my websites loong ago, I think it was during 1.5 and it seems title function didn't change from then, so this should work on 1.6 as well, but backup and test first!

I called it "hardcoded pages titles mod" and this is the modified title() function:
Quote
// TITLE
function title() {
   echo '<base href="'.db('website').'" />';
   $categorySEF = get_id('category'); $articleSEF = get_id('article');
   $categoryName = retrieve('name', 'categories', 'seftitle', $categorySEF);
   $articleTitle = retrieve('title', 'articles', 'seftitle', $articleSEF);
//Dom: hardcoded pages titles mod
   if ($categorySEF == "") {$title = s('website_title')."&nbsp;"."Home";}
      elseif ($categorySEF == "contact") {$title = s('website_title')."&nbsp;"."Contact";}
      elseif ($categorySEF == "archive") {$title = s('website_title')."&nbsp;"."Archive";}
      elseif ($categorySEF == "sitemap") {$title = s('website_title')."&nbsp;"."Sitemap";}
      elseif (!empty($articleTitle)) {$title = $articleTitle;}
      elseif (!empty($categoryName)) {$title = $categoryName;}

   echo '<title>'.$title.'</title>';
   echo '<meta http-equiv="Content-Type" content="text/html; charset='.s('charset').'" />';
   if (!empty($articleSEF)) {
      $query = "SELECT * FROM ".db(prefix)."articles WHERE seftitle = '$articleSEF'";
      $result = mysql_query($query);
      while ($r = mysql_fetch_array($result)) {$dmeta = $r['description_meta']; $kmeta = $r['keywords_meta'];}
   }
   echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta : s('website_description')).'" />';
   echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta : s('website_keywords')).'" />';
   if ($_SESSION[db('website').'Logged_In'] == token()) {js();}
}

EDIT: there was an error in the code pointed out by funlw65. Thanks!
« Last Edit: April 22, 2008, 03:03:29 PM by Dom »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #2 on: April 22, 2008, 02:30:29 PM »

Dom, a little error in your code:

Replace this line:
elseif ($categorySEF == "archives") {$title = s('website_title')."&nbsp;"."Articles";}
With:
elseif ($categorySEF == "archive") {$title = s('website_title')."&nbsp;"."Archive";}
Logged

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 163
    • domdelimar.com
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #3 on: April 22, 2008, 03:01:50 PM »

Thanks funlw65!
I apologize for this. I now remember I modified that instance of sNews so that the link http://example.com/archive/ becomes http://example.com/archives/.

And just as I have, you can play with the titles by changing these parts of the code:

{$title = s('website_title')."&nbsp;"."Home";} >> this will say "{website title} Home" of course...
{$title = s('website_title')."&nbsp;"."Contact";}
{$title = s('website_title')."&nbsp;"."Archive";}
{$title = s('website_title')."&nbsp;"."Sitemap";}
Logged

maxou

  • Jr. Member
  • **
  • Karma: 5
  • Posts: 81
  • Bug's Finder
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #4 on: April 22, 2008, 03:58:56 PM »

Thanks Dom and Mr Fun, it works. ;)

Is it possible to make the same thing with meta description and meta keyword ?
Logged
Work on XAMPP.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #5 on: April 22, 2008, 05:13:13 PM »

Thanks Dom and Mr Fun, it works. ;)

Is it possible to make the same thing with meta description and meta keyword ?
Thanks Dudes! That's a pretty good idea.
Maxou did you check pages?
It seems (only for pages) that title is being duplicated.
It appears twice:
Quote
title's pagetitle's page
Quote
function title() {
   echo '<base href="'.db('website').'" />';
   $categorySEF = get_id('category'); $articleSEF = get_id('article');
   $categoryName = retrieve('name', 'categories', 'seftitle', $categorySEF);
   $articleTitle = retrieve('title', 'articles', 'seftitle', $articleSEF);
   //Dom: hardcoded pages titles mod
   if ($categorySEF == "") {$title = s('website_title')."&nbsp;-&nbsp;"."Accueil";}
      elseif ($categorySEF == "contact") {$title = s('website_title')."&nbsp;-&nbsp;"."Contact";}
      elseif ($categorySEF == "archives") {$title = s('website_title')."&nbsp;-&nbsp;"."Archives";}
      elseif ($categorySEF == "sitemap") {$title = s('website_title')."&nbsp;-&nbsp;"."Plan du site";}
     elseif ($categorySEF == "articles") {$title = s('website_title')."&nbsp;-&nbsp;"."Blog";}
      elseif (!empty($articleTitle)) {$title = $articleTitle;}
      elseif (!empty($categoryName)) {$title = $categoryName;}

   // EQ Add 4 lines   
   $search = dashstrip($_GET['search']);
   if (!empty($search)) { $title = $search;}
   if (!empty($articleTitle)) { $title .= $articleTitle.' - ';}
   if (!empty($categoryName)) { $title .= $categoryName.' - ';}
   if (empty($search)) { $title .= s('website_title'); }
   echo '<title>'.$title.'</title>';
   echo '<meta http-equiv="Content-Type" content="text/html; charset='.s('charset').'" />';
   if (!empty($articleSEF)) {
      $query = "SELECT * FROM ".db(prefix)."articles WHERE seftitle = '$articleSEF'";
      $result = mysql_query($query);
      while ($r = mysql_fetch_array($result)) {$dmeta = $r['description_meta']; $kmeta = $r['keywords_meta'];}
   }
   // EQ add 10 lines
   if (!empty($search)) {    
      echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta : s('website_description')).' Tag - '.$search.'" />';
   } else {
      echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta : s('website_description')).'" />';
   }
   if (!empty($search)) {
      echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta : s('website_keywords')).','.$search.'" />';
   } else {
      echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta : s('website_keywords')).'" />';
   }
   if ($_SESSION[db('website').'Logged_In'] == token()) { js();}

   //Mod Expandable comments
   toggle_div();
}
???

maxou

  • Jr. Member
  • **
  • Karma: 5
  • Posts: 81
  • Bug's Finder
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #6 on: April 22, 2008, 05:23:54 PM »

Hmm with Dom's code no problem with pages : "title page"
Logged
Work on XAMPP.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #7 on: April 22, 2008, 05:40:27 PM »

Oh!
You don't use Tags Mod.

With EQ's Mod correct code is:
Quote
...
$articleTitle = retrieve('title', 'articles', 'seftitle', $articleSEF);
      // EQ Add 4 lines   
   $search = dashstrip($_GET['search']);
   if (!empty($search)) { $title = $search;}
   if (!empty($articleTitle)) { $title .= $articleTitle.' - ';}
   if (!empty($categoryName)) { $title .= $categoryName.' - ';}
   if (empty($search)) { $title .= s('website_title'); }
   //Dom: hardcoded pages titles mod
...
« Last Edit: April 22, 2008, 05:45:49 PM by Sven »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #8 on: April 22, 2008, 06:03:19 PM »

Code: [Select]
<?php
// TITLE

function title() {

echo '<base href="'.db('website').'" />';
$categorySEF get_id('category'); $articleSEF get_id('article');
$categoryName retrieve('name''categories''seftitle'$categorySEF);
$articleTitle retrieve('title''articles''seftitle'$articleSEF);
$search dashstrip($_GET['search']); //<-- I moved EQ code here

//DOM-MOD(
   
if ($categorySEF == "") {$title s('website_title')."&nbsp;"."Home";}
   if (
$categorySEF == "blog") {$title s('website_title')."&nbsp;"."Blog";}
   if (
$categorySEF == "contact") {$title s('website_title')."&nbsp;"."Contact";}
   if (
$categorySEF == "archive") {$title s('website_title')."&nbsp;"."Archive";}
   if (
$categorySEF == "sitemap") {$title s('website_title')."&nbsp;"."Sitemap";}
   if (!empty(
$articleTitle)) {$title $articleTitle;}
   if (!empty(
$categoryName)) {$title $categoryName;}
   if (!empty(
$search)) {$title s('website_title')."&nbsp;".$search;}

//)

/* // EQ Add 4 lines
$search = dashstrip($_GET['search']);
if (!empty($search)) { $title = $search.' - ';}
if (!empty($articleTitle)) { $title .= $articleTitle.' - ';}
if (!empty($categoryName)) { $title .= $categoryName.' - ';}
//if (!empty($articleTitle)) {$title = $articleTitle.' - ';}
//if (!empty($categoryName)) {$title .= $categoryName.' - ';}
$title .= s('website_title');
*/

echo '<title>'.$title.'</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset='.s('charset').'" />';
if (!empty($articleSEF)) {
//$query = "SELECT * FROM ".db(prefix)."articles WHERE seftitle = '$articleSEF'";
    
$query "SELECT description_meta,keywords_meta FROM ".db(prefix)."articles WHERE seftitle = '$articleSEF'";
$result mysql_query($query);
while ($r mysql_fetch_array($result)) {$dmeta $r['description_meta']; $kmeta $r['keywords_meta'];}
}

// EQ add 10 lines
if (!empty($search)) { 
echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta s('website_description')).' Tag - '.$search.'" />';
} else {
echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta s('website_description')).'" />';
}
if (!empty($search)) { 
echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta s('website_keywords')).','.$search.'" />'
} else {
echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta s('website_keywords')).'" />';
}

// echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta : s('website_description')).'" />';
// echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta : s('website_keywords')).'" />';

  
js_global();

//whizzywig editor MOD ( - MOD DISABLED
if ($_SESSION[db('website').'Logged_In'] == token()) {js();}
  
//if ($_SESSION[db('website').'Logged_In'] == token()) {js();
  //  echo '<script type="text/javascript" src="whizzywig.js"></script>';
  //  echo '<script type="text/javascript" src="xhtml.js"></script>';
  //}
//)

//smilies buttons in comments form by Rui Mendes(
js1();
//)
}


Hi Mr.Sven, I`m using this title function, with code from Dom but modified....
You can get rid of js1(); function from bottom...
I don`t know if is working for you.
« Last Edit: April 22, 2008, 06:09:22 PM by funlw65 »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #9 on: April 22, 2008, 06:17:20 PM »

Hi Mr Fun
Howdee?  :)
I thought I've fixed the issue but your smart piece of code works better.
Thanks a lot Vasile. 8)
« Last Edit: April 22, 2008, 06:23:29 PM by Sven »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #10 on: April 22, 2008, 06:30:28 PM »

Code: [Select]
<?php
   
if ($categorySEF == "contact") {
      
$title s('website_title')."&nbsp;"."Contact";
      
$dmeta='your-description-here';
      
$kmeta='your-keywords-here';
   }
   if (
$categorySEF == "archive") {
      
$title s('website_title')."&nbsp;"."Archive";
      
$dmeta='your-description-here';
      
$kmeta='your-keywords-here';
   }
   if (
$categorySEF == "sitemap") {
      
$title s('website_title')."&nbsp;"."Sitemap";
      
$dmeta='your-description-here';
      
$kmeta='your-keywords-here';
   }

Hi Maxou,
You can try this...

Mr.Sven,
You can do the same but make also for blog page....
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #11 on: April 22, 2008, 06:39:39 PM »

Splendid Mr Fun!
Vasile: you're a chef!!! ;D
Free distribution of karmas for all. 8)

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #12 on: April 22, 2008, 06:41:24 PM »

Thank you Mr.Sven, just changed a little Dom`s code...
Logged

maxou

  • Jr. Member
  • **
  • Karma: 5
  • Posts: 81
  • Bug's Finder
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #13 on: April 22, 2008, 07:28:51 PM »

I'm stupid, it was not complicated ... this summer I will learn PHP to realise my ideas.  8)

thanks !  ;)
xx karmas !!!
Logged
Work on XAMPP.

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: home,archive,sitemap,contact risk a duplicate content !!
« Reply #14 on: April 23, 2008, 12:10:28 AM »

UPDATE 04 May 2008:
Added description meta and keyword meta for category. See inside code.

Code: [Select]
<?php
// TITLE

function title() {
   echo 
'<base href="'.db('website').'" />';
   
$categorySEF get_id('category'); $articleSEF get_id('article');
   
$categoryName retrieve('name''categories''seftitle'$categorySEF);
   
$articleTitle retrieve('title''articles''seftitle'$articleSEF);
   
$search dashstrip($_GET['search']);

//DOM-MOD(
   
if ($categorySEF == "") {$title s('website_title')."&nbsp;"."Home";}
   if (
$categorySEF == "blog") {
      
$title s('website_title')."&nbsp;"."Blog";
      
$dmeta='The blog page of '.db('website');
      
$kmeta='blog, journal, jurnal';
   }
   if (
$categorySEF == "contact") {
      
$title s('website_title')."&nbsp;"."Contact";
      
$dmeta='The contact page of '.db('website');
      
$kmeta='contact, information';
   }
   if (
$categorySEF == "archive") {
      
$title s('website_title')."&nbsp;"."Archive";
      
$dmeta='The archive page of '.db('website');
      
$kmeta='archive';
   }
   if (
$categorySEF == "sitemap") {
      
$title s('website_title')."&nbsp;"."Sitemap";
      
$dmeta='The sitemap page of '.db('website');
      
$kmeta='sitemap, google, index';
   }
    if (!empty(
$categoryName)) {  //<-- new addition, like NaEnr mod...
      
$title $categoryName;
      
$dmeta='All articles under '.$title.' category';
      
$kmeta=$title;      
   }

   if (!empty(
$articleTitle)) {$title $articleTitle;}
   if (!empty(
$search)) {
      
$title s('website_title')."&nbsp;".$search;
      
$dmeta='Looking for '.$search.' tag on '.db('website');
      
$kmeta=$search;      
   }
//)

    
echo '<title>'.$title.'</title>';
    echo 
'<meta http-equiv="Content-Type" content="text/html; charset='.s('charset').'" />';
    if (!empty(
$articleSEF)) {
            
$query "SELECT description_meta,keywords_meta FROM ".db(prefix)."articles WHERE seftitle = '$articleSEF'";
    $result mysql_query($query);
    while ($r mysql_fetch_array($result)) {$dmeta $r['description_meta']; $kmeta $r['keywords_meta'];}
    }
    echo 
'<meta name="description" content="'.(!empty($dmeta) ? $dmeta s('website_description')).'" />';
    echo 
'<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta s('website_keywords')).'" />';
    
js_global();

//whizzywig editor MOD ( - MOD DISABLED
    
if ($_SESSION[db('website').'Logged_In'] == token()) {js();}
    
//if ($_SESSION[db('website').'Logged_In'] == token()) {js();
    //  echo '<script type="text/javascript" src="whizzywig.js"></script>';
    //  echo '<script type="text/javascript" src="xhtml.js"></script>';
    //}
//)

//smilies buttons in comments form by Rui Mendes(
js1();
//)
}


My final title() function (using Tags mod by Equilni and js1 function for another mod). Of course, this mod can be made with language variables.
« Last Edit: May 03, 2008, 11:03:13 PM by funlw65 »
Logged
Pages: [1] 2 3