Yii, SEO, registerResource

Hi,

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?

Thanks

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:

http://yiiframework.com/doc/api/1.1/CClientScript#coreScriptPosition-detail

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=Yii::app()->getClientScript();

$cs->registerCoreScript(‘jquery’);

$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 ?

Thanks

Works perfect.


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

		$cs->registerCoreScript('jquery');

		

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

		$cs->registerScriptFile($url.'/tinymce/jscripts/tiny_mce/tiny_mce.js',CClientScript::POS_END);

		$cs->registerScriptFile($url.'/js/admin.js',CClientScript::POS_END);

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

					mode : "textareas",

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

				});',CClientScript::POS_END);

		$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:

http://www.webmasterworld.com/google/3156806.htm

http://sixrevisions.com/content-strategy/5-common-seo-mistakes-with-web-page-titles/

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)