ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to include post title & content in meta title & meta description

July 23, 2010 10:54am

Subscribe [4]
  • #1 / Jul 23, 2010 10:54am

    Stoelting

    99 posts

    I would like the title of posts to be placed in the meta title tag and the opening 140 characters of the content included in the meta description tag.

    I think I saw an add on to dynamically create meta tags based on post, but have not been able to find it today. Not sure how to limit inclusion to first 140 chars.

    Is any of this capability now built into EE 2?

  • #2 / Jul 23, 2010 11:01am

    Boyink!

    5011 posts

    Put your html header info in an embedded template.

    Then pass the meta stuff through using embed variables for embedded templates.

    Use the Character Limiter to set the l40 - you’ll probably also need the Strip HTML plugin to remove markup.

    This approach will work in EE 1 or 2.

  • #3 / Jul 23, 2010 11:01am

    Ingmar

    29245 posts

    You can easily do that by using another weblog:entries tag. To shorten the body to 140 characters you’d use a plugin. There are also third-party add-ons like LG Better Meta.

  • #4 / Jul 23, 2010 11:31am

    Stoelting

    99 posts

    Would this be the correct code to place in the head section of the template?

    {exp:weblog:entries weblog="{master_weblog_name}"}
    <META NAME="title" CONTENT="{title}" />
    <META NAME="description" CONTENT="{exp:char_limit total="100"}{article_content}{/exp:char_limit}" />
    {/exp:weblog:entries}

    The LG add-on looks like it gives lots of options, but does not appear that could be applied to existing posts (i.e. it would only apply to posts after it is installed and added to the template.) I have about 1200 existing posts I would like this applied to.

  • #5 / Jul 23, 2010 11:35am

    Ingmar

    29245 posts

    Yes, something like your snippet should work. Be sure to use the disable= parameter, too. Also, you might want to limit it to 1 entry.

  • #6 / Jul 23, 2010 12:03pm

    Stoelting

    99 posts

    Thanks. This is exactly what I needed.

  • #7 / Jul 23, 2010 4:48pm

    Brandon Jones

    5500 posts

    Thanks for the input, all. Glad you have a solution!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases