SEO meta tags on each page.

I am trying to extract excerpts to display in meta description on each page of elgg 1.8.8. Something like that.

<meta name="description" content="<?php echo $excepts; ?>" />

<meta name="keywords" content="<?php echo $tags; ?>" />

I found this article to this but it is for 1.7

I asked same question in community but nobody reply.

I really appriciate if you give me some right directions on this.

Below is a link to community discussion. I also mention some more code there.

Click here

Thanks

  • This a dirty solution (tested on Elgg 1.7.15)

    <?php

    if (empty($vars['title'])) {

    $title = $vars['config']->sitename;

    }

    else

    if (empty($vars['config']->sitename)) {

    $title = $vars['title'];

    }

    else {

    $title = $vars['title'] . " - " . $vars['config']->sitename;

    }

    $type = get_input('expages');

    if($type == 'about') {

    $title = elgg_echo('expages:about') . " - " . $vars['config']->sitename;

    }

    else if($type == 'terms') {

    $title = elgg_echo('expages:terms') . " - " . $vars['config']->sitename;

    }

    else if($type == 'privacy') {

    $title = elgg_echo('expages:privacy') . " - " . $vars['config']->sitename;

    }

    ?>

    <!DOCTYPE html><html><head>

    <title><?php echo $title; ?></title>

    <meta name="description" content="<?php echo $title; ?>" />

    <meta name="keywords" content="<?php echo $vars['title']; if (empty($vars['title'])) { echo $title; } ?>" />

     

    Now you need to re-work it with the $excepts and $tags ;)

  • RVR thanks, For title every thing is working. Please some one from core team help me why below codes are not displaying any contents?

    I am trying to display discription by following codes.

    $excerpt = elgg_get_excerpt($vars['entity']->description, 20);

    or

    $desc = elgg_extract('description', $vars, '');
    
    $tags = elgg_extract('tags', $vars, '');
  • elgg_get_excerpt($vars['entity']->description, 20); is wrong code - check some live examples in plugins...

  • For blogs:-

    $excerpt = $blog->excerpt;
    if (!$excerpt) {
        $excerpt = elgg_get_excerpt($blog->description);
    }

    Do I need to set for each case or I can change code like below:-

    $excerpt = $vars['entity']->excerpt;
    if (!$excerpt) {
        $excerpt = elgg_get_excerpt($vars['entity']->description);
    }

  • I also tried below code but it only display </ b>

    $description = autop($vars['entity']->description);

  • Please experts help me and this will be useful for everyone!

    Many thanks in advance

    Regards

  • BING is very clear about Meta discription but nobody is paying attention on these things, after 6 days no reply.

  • What's not working?  Are you sure your entity has a description? Not all of them do.  Also, not all pages have an entity passed in $vars

  • Hi Matt,

    I tried upper codes but always get a blank discription.

    As tidypics,albums,media plugin and blog plugin has discription entity. So I was checking with that. I am very confused with this.

    Please help me. Bing send me message saying your contents don't have discription tag. and I heard duplicate meta discription is also bad for seo.

  • $excerpt = $vars['entity']->excerpt;
    if (!$excerpt) {
        $excerpt = elgg_get_excerpt($vars['entity']->description);
    }
    should woiky oki-doki..
    as long as there's the source data available (as Matt points out;)
    'always get a blank description...' => always got no excerpt or no entity !;-oO
    what de heck r u doin` w/ autop in there ?
    seems like u r trying odd snippets of 5/8 random code...
    wrng approach ! try and mnake sure that you have got the correct entity and
    it's description loaded -- that is the first step - the rest will follow naturally.