Yii, SEO, registerResource


I see that when you register javascript or css style, Yii insert those resources at the very begin of the head html statement.

Then title html statement is quite far from the top of the file.

And Search Engine like the title statement at the top of the html file.

is there a way to indicate to Yii that he has to place its resources in another part of the header?


Sorry to poluate forum with 2 identical post. But when I posted I get an SQL Error message. Then I try again and I saw my 2 identical posts

sorry :blink:

Duplicate post deleted

Google likes the TITLE statement… it’s place is in the HEAD section… it’s not important where TITLE is located as long as it is in the HEAD section…

How do you register javascript or css styles?

Check these resources:


In fact check all the CClientScript class - http://yiiframework.com/doc/api/1.1/CClientScript all methods for registering scripts has the property ‘position’

Many many thanks mdomba for your reply.

(I thought I was alone)

Google Like Title at the very first place in html document. Some years in SEO lead me think I’m right.

But Ok I can admit I’m wrong also, because I’m not in Google mind.

I write :



$cs->coreScriptPosition = CClientScript::POS_END;

I would have prefer to have the capability to insert it AFTER the TITLE.

In the case I would like to add this possibility, then extending a Core class, Where can I place my own CClientScript class ?


Works perfect.

<?php $cs=Yii::app()->getClientScript();



		$url = Yii::app()->request->baseUrl;



		$cs->registerScript('js1','	tinyMCE.init({

					mode : "textareas",

					theme : "simple"   //(n.b. no trailing comma, this will be critical as you experiment later)


		$cs->coreScriptPosition = CClientScript::POS_END;


Every things are located at the end of body, in respect (order) of the declared statements.

You are not alone, it’s just that on work-days there are more usrs visiting the forum…

As for the TITLE there is no reason why should google want it above… TITLE should be in the HEAD section… and that’s all… google will find it if it’s there… it’s better to pay attention what is written in the TITLE then where it is…

Check this discussion on TITLE position - http://www.webproworld.com/webmaster-forum/threads/13840-Does-Title-Tag-Placement-Matter-In-Regards-To-SEO

Anyway if you want your <title> to be just below the <head>, edit <your project>/protected/view/layout/main.php and put the TITLE element where you want it… :)

Some more SEO info on TITLE:



Concerning TITLE I feel it is a never end story. Others very good specialist said the importance of placing head as I previously said. But anyway, you’re right when you said the content of Title is more important.

I do not understand your hints ‘editing the main layout file and placing the TITLE as I want’

If I use a widget like CGridView it will place the js and Css at the top, just before Title.

I can indicate js to be place in body, but I can’t tell css to be placed just After Title for instance.

In the case you’re right regarding Title position importance vs Google then it is not a problem.

In the case you’re wrong, it would be an enhancement.

As final statement I could argue that no one could know the Google strategy regarding head analyse (how much code from <head> to </html> is it necessary to determine the duplicate content, and so on) then It would be great to said insert your registered js script and css Before or after an Html Tag.

The web article you pointed is of 2003. Things could also change (example meta keywords has less importance now)