Closed DuskoV closed 11 years ago
@DuskoV, it would be much better for reviewers if you created pull request instead of posting code as plain text.
I find it not SEO friendly to have styles, and other stuff included before
Whats the problem with that?
The problem is that <title>
is pushed to the bottom in the <head>
. Some crawlers might think of this to be strange. Also, if people have invalid HTML in the <head>
, then it's also more possible that <title>
isn't red correctly.
@DuskoV all current search engine crawlers are reading titles regardless of where it's in the <head>
. Also it's valid according to all HTML specs.
Any reason to have invalid HTML in the <head>
of your own pages?
It's unfounded that this would affect SEO.
We cannot change the location now because it would break BC. By putting the scripts at the bottom of head, it also makes it impossible for developers to override these scripts.
I find it not SEO friendly to have styles, and other stuff included before
Here is the code of the function, how it looks after my changes:
Here is description of changes:
1) Change at begining (line #352 and #354) $html='';$mtags=''; foreach($this->metaTags as $meta) $mtags.=CHtml::metaTag($meta['content'],null,null,$meta)."\n";
2) Then added, right before "if($html!=='')": if (!empty($mtags)) { $count=0; $output=pregreplace('/(<\/title\b[^>]>)/is','$1<###title###>',$output,1,$count); if($count) $output=str_replace('<###title###>',$mtags,$output); else { $output=pregreplace('/(<\/head\s>)/is','<###head###>$1',$output,1,$count); if($count) $output=str_replace('<###head###>',$mtags,$output); else $output=$mtags.$output; } }
3) And last, replaced line: $output=pregreplace('/(<title\b[^>]>|<\/head\s_>)/is','<###head###>$1',$output,1,$count);
with: $output=preg_replace('/(<\/head\s*>)/is','<###head###>$1',$output,1,$count);