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 get title tags right.

January 26, 2009 7:15pm

Subscribe [1]
  • #1 / Jan 26, 2009 7:15pm

    jontusmedia

    20 posts

    I have recently changed my blog to use the following url structure:

    mydomain.com (index page)
    mydomain.com/article_title

    The articles (or blog posts) don’t have a separate template anymore and are formed from the index file so I get pretty permalinks.

    The Problem
    Since I set this up the new url structure the title tags have gone from my articles and the name of my site is now on every title tag instead of the name of the article.

    How can I ensure that the index page (domain.com) shows “My site” as the title tag, but each article (mydomain.com/article_title) puts the article title in the title tag instead so I get “Article Title - My Site” when I am using just the index page to create my blog.

    Previously I was using the following tags on a separate template for individual articles:

    title="{exp:weblog:entries weblog="weblog" limit="1" status="open"}{title}{/exp:weblog:entries}"}

    Having scrapped the article template to just use the index page, now only My Site shows as the title for all the articles.

    Any suggestions gratefully received!

  • #2 / Jan 26, 2009 7:30pm

    liquilife

    147 posts

    What about using a URL segment conditional? Something like:

    <title>{if segment_1 > ''}{exp:weblog:entries weblog="weblog" limit="1" status="open"}{title}{/exp:weblog:entries} - {/if}Site name</title>

    I’m also assuming you are referring to the title tag in the head of an HTML document, right?

  • #3 / Jan 26, 2009 7:47pm

    jontusmedia

    20 posts

    Darn, that worked! Thanks so much.

  • #4 / Jan 26, 2009 7:49pm

    liquilife

    147 posts

    You are welcome. Glad it worked for you!

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

ExpressionEngine News!

#eecms, #events, #releases