GetSimple Support Forum
Custom index page <title> tag - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Scripts & Components (http://get-simple.info/forums/forumdisplay.php?fid=11)
+--- Thread: Custom index page <title> tag (/showthread.php?tid=1810)



Custom index page <title> tag - Carlos - 2011-06-05

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.


Custom index page <title> tag - Carlos - 2011-06-11

I've edited the post, as the Innovation theme has the <title> tag in header.php instead of template.php


Custom index page <title> tag - ccagle8 - 2011-06-12

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.


Custom index page <title> tag - sal - 2011-06-12

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); ?>



Custom index page <title> tag - Carlos - 2011-06-12

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...


Custom index page <title> tag - Carlos - 2011-06-12

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.


Custom index page <title> tag - polyfragmented - 2011-06-27

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();                        
        }                
    ?>



Custom index page <title> tag - Carlos - 2011-06-27

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.


Custom index page <title> tag - polyfragmented - 2011-06-27

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.