Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom index page <title> tag
#1
If you want your homepage to have a customized title tag different to the default for all pages, you can do this.

1. Create a component 'titletag' with this content (edit 2nd and 4th lines to what you wish):
Code:
<?php if (return_page_slug()=='index') { ?>
This is my homepage's custom title tag...
<?php } else { ?>
<?php get_page_clean_title(); ?> - <?php get_site_name(); ?>
<?php } ?>
2. Edit your theme's template.php file (and/or others...) or header.php (if using Innovation theme), look for the <title>...</title> line and replace it with:
Code:
<title><?php get_component('titletag'); ?></title>

That's it.
Reply
#2
I've edited the post, as the Innovation theme has the <title> tag in header.php instead of template.php
Reply
#3
I've something like this before, but with the custom fields plugin - then calling the new field for the title if that partiular custom field is populated for that page.
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#4
I usually only need to change the homepage's title too so usually just use this directly in the template.
Code:
<?php echo (get_page_slug(false) == 'index') ? 'Homepage title' : get_clean_title(false) . ' &ndash; ' . get_page_site_name(false); ?>
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Reply
#5
sal Wrote:I usually only need to change the homepage's title too so usually just use this directly in the template [...]

I have also used that way. But the code you're inserting in your template(s) could be in the component I suggest. :-)

This way it is easier to work with when you have several templates, or if you change your theme.
I also find this faster, not having to locate the <title> line in your template file...
Reply
#6
ccagle8 Wrote:I've something like this before, but with the custom fields plugin - then calling the new field for the title if that partiular custom field is populated for that page.

Yeah, I thought about something like that (or did I read it here?).
Another (better?) solution would be having a plugin for this, as I suggested in another thread.

But anyway I think that this 'titletag' component solution is a nice an easy one for most cases where you just want to do some SEO with your homepage.
Reply
#7
Something I implemented today for my H1 page heading by way of I18N Custom Fields. This outputs the custom field if it is populated:

Code:
<?php            
        if (return_custom_field('ueberschrift')) {                    
            get_custom_field('ueberschrift');                    
        } else {                    
            get_page_title();                        
        }                
    ?>
Reply
#8
polyfragmented Wrote:Something I implemented today for my H1 page heading by way of I18N Custom Fields.

So you're doing like Chris, but exchanging fields: the <title>... tag will always show the Page title field, but the body heading (<h1>...) your custom title (if defined).
Interesting, a different approach.
Reply
#9
Carlos Wrote:So you're doing like Chris, but exchanging fields: the <title>... tag will always show the Page title field, but the body heading (<h1>...) your custom title (if defined).
Interesting, a different approach.
Oh, I actually apply this to the page title as well, but with yet another custom field. I just found it limiting to have a page called, say, "Search" with the same title and a H1 callled the same short string.

Here's my titel tag v00d00, a little compressed:

Code:
<title><?php if (return_custom_field('titel')) {get_custom_field('titel'); echo ' – '; get_site_name();} else {get_page_clean_title(); echo ' – ';  get_site_name();}    ?></title>

From a SEO point-of-view it's better to have the desired keywords in both the title and the H1 element, but with this approach, I'm more flexible text-wise.
Reply




Users browsing this thread: 4 Guest(s)