SEO Page Title - Free Modification

As you know, CS-Cart generates Page Titles like so for Categories and Products:-

[quote]

Electronics :: Computers :: Laptops :: Gaming Laptops

Electronics :: Computers :: Laptops :: Gaming Laptops :: Alienware M18X Laptop

[/quote]

Wouldn’t it be better to have your page title like this, conforming to best practises:

[quote]

Gaming Laptops - Laptops - Computers - Electronics

Alienware M18X Laptop - Gaming Laptops - Laptops - Computers - Electronics



[/quote]

Well now you can change it to a more SEO-friendly structure. The “most important” keywords should be placed at the beginning of your Page Title, not at the end as default. So here’s a quick, simple way to fix that.



Note, this only has an effect on products and categories where you have not added your own page title. This functionality replaces the default generation of the page title when it is otherwise blank.



Please make a back-up of any files you change before making any edits live on your site.



Open, depending on your CS-Cart version (Professional or Ultimate, # denotes Store ID):


/skins/your-skin/customer/index.tpl
```<br />
OR<br />
```php
/stores/#/skins/your-skin/customer/index.tpl
```<br />
<br />
Locate this code:<br />
```php
{strip}<br />
<title><br />
{if $page_title}<br />
	{$page_title|escape:"html"}<br />
{else}<br />
	{foreach from=$breadcrumbs item=i name="bkt"}<br />
		{if !$smarty.foreach.bkt.first}{$i.title|unescape|strip_tags|escape:"html"}{if !$smarty.foreach.bkt.last} :: {/if}{/if}<br />
	{/foreach}<br />
	{if !$skip_page_title}{if $breadcrumbs|count > 1} - {/if}{$location_data.title|escape:"html"}{/if}<br />
{/if}<br />
</title><br />
{/strip}
```<br />
And replace it with this code:<br />
```php
<br />
{strip}<br />
<title><br />
{if $page_title && $controller != 'products' && $controller != 'categories'}<br />
	{$page_title|escape:"html"}<br />
{else}<br />
	{foreach from=$breadcrumbs|array_reverse item=i name="bkt"}<br />
		{if !$smarty.foreach.bkt.last}{if !$smarty.foreach.bkt.first} - {/if}{$i.title|unescape|strip_tags|escape:"html"}{/if}<br />
	{/foreach}<br />
	{if !$skip_page_title}{if $breadcrumbs|count > 1} - {/if}{$location_data.title|escape:"html"}{/if}<br />
{/if}<br />
</title><br />
{/strip}<br />

```<br />
<br />
This modification is tried and tested in V2.2.X and V3.0.X. It may also work for previous versions, but I am unable to test on 2.1.X or below.

Thank you StellarBytes.

Bummer there's no hook there so the original file doesn't have to be modified.

Very interesting and cool. Honestly never realized I have probably been doing this wrong for some time now. Now I see that I should not be putting anything in the “page title” field, but I cannot seem to get it to switch around like you are saying. Is there something other than the code you have here that I need to have set different on the site?

the “|array_reverse” should be reversing the breadcrumbs…

Hi



This is a nice solution.



Only downsize is that if you want to customize you categories title description it's not possible.



Is there a way around like an if the title fils is empty then…use this if not then use custom field plus site name.



Fotis

Someone would have to extend the data for the product and category. Products have the cscart_product_data field to store additional “stuff” related to a product however I'm not aware of a similar one for categories. In any event, someone would have to use the available hooks and develop the pre/post controllers to support the new data.



But why not just put what you want in the page title field if you're going to add a new field for customized info?

Thats standard use already in CS-Cart, I was jsut saying that if I want stronger SEO then I need my own meta title and the store name at the end. inorder to avoid rewritng it over and over again.

I thought someone had posted some free modification that would allow you to specify your page title using variable names… I don't use it so you'll have to look.

I guess you could also use the free mod at…

http://1clue.com/dynamic-page-titles.html

…that does a similar type thing. This may be the one that tbirnseth is speaking of too.

Hi clips



I am aware of that, but it doesn't support categories. Just products and pages.

The nice thing about the add-on from 1clue is you don't have to change any core files plus you can change them to any direction you want and add more stuff, like the price. We'll see if it helps.

Hi guys



returning on this about v4



Now there is a hook in title {hook name=“index:title”} so you can just open in my_changes folder (located in /design/themes/YOUR_THEME/templates/addons/) a folder with the name index and inside put the file title.override.tpl with this content



{if $page_title && $controller != 'products' && $controller != 'categories'}
{$page_title|escape:"html"}
{else}
{foreach from=$breadcrumbs|array_reverse item=i name="bkt"}

{if !$smarty.foreach.bkt.last} {if !$smarty.foreach.bkt.first} - {/if}{$i.title|strip_tags}{/if}

{/foreach}
{if !$skip_page_title && $location_data.title}{if $breadcrumbs|count > 1} - {/if}{$location_data.title}{/if}
{/if}




Now your Categories Pages look like this



Natural Gut - Babolat - Grids



instead of this



Grids :: Babolat :: Natural Gut



Tested in 403 and 415 ([url=“http://leweb.gr/cs415/index.php?dispatch=categories.view&category_id=168”]http://leweb.gr/cs41...category_id=168[/url])



Thats all



Fotis

One more addition to this



If you add the


| {$settings.Company.company_name}



right after



{foreach from=$breadcrumbs|array_reverse item=i name="bkt"}

{if !$smarty.foreach.bkt.last} {if !$smarty.foreach.bkt.first} - {/if}{$i.title|strip_tags}{/if}

{/foreach}




and after



{if $page_title && $controller != 'products' && $controller != 'categories'}
{$page_title|escape:"html"}




then you get the company name added right after the Title, of you page like this





Desktops - Computers - Electronics | Simtech



Fotis

design/themes/responsive/templates/addons/seo/hooks/index/meta.post.tpl
{if $languages|sizeof > 1}
{$default_language = $languages[$settings.Appearance.frontend_default_language]}
{foreach from=$languages item="language"}
{/foreach}
{/if}
can we but each multi site name in store title
like this
simtech site
Desktops - Computers - Electronics | Simtech
cs-cart site
Desktops - Computers - Electronics | cs-cart

can we but each multi site name in store title
like this
simtech site
Desktops - Computers - Electronics | Simtech
cs-cart site
Desktops - Computers - Electronics | cs-cart

Try to add the following code at the end

{$company.company_id|fn_get_company_name}

Note that you provided code for languages not for store-fronts

Tanks for help i test in meta.post.tpl. i put in at the top in it

{$settings.Company.company_name}

it show in main store name but your share code is nothing to do.

and can you share the all code we see correctly way :)

Tanks for help i test in meta.post.tpl. i put in at the top in it

{$settings.Company.company_name}

it show in main store name but your share code is nothing to do.

and can you share the all code we see correctly way :)

In CS-Cart (not Multi-Vendor) please try

{$runtime.company_id|fn_get_company_name}
Dear ecomlabs
Thanks for sharing its work. but can you help, its the right place because I can not see how gogle sees my title. i look arround but cant find live test.
{if $languages|sizeof > 1}
{$default_language = $languages[$settings.Appearance.frontend_default_language]}
{$runtime.company_id|fn_get_company_name}
{foreach from=$languages item="language"}
{$runtime.company_id|fn_get_company_name}
{/foreach}
{/if}
Thanks for all..

Page title can be adjusted in the following file

design/themes/THEME/templates/index.tpl

{capture name="page_title"}
{hook name="index:title"}
{if $page_title}
    {$page_title}
{else}
    {foreach from=$breadcrumbs item=i name="bkt"}
        {if !$smarty.foreach.bkt.first}{$i.title|strip_tags}{if !$smarty.foreach.bkt.last} :: {/if}{/if}
    {/foreach}
    {if !$skip_page_title && $location_data.title}{if $breadcrumbs|count > 1} - {/if}{$location_data.title}{/if}
{/if}
{/hook}
{/capture}
{$smarty.capture.page_title|strip|trim nofilter}