• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customizing Title and Meta Tag for SEO

please note that the following is just my personal opinion.

echo "<META http-equiv='Content-Type' content='text/html; charset=utf-8' />"."\n";
echo "<TITLE>".$html_title."</TITLE>"."\n";
echo "<META name='title' content='".$meta_title."' />"."\n";
echo "<META http-equiv='expires' content='".$expires."' />"."\n";
echo "<META http-equiv='pragma' content='".$pragma."' />"."\n";
echo "<META name='author' content='".$meta_author."' />"."\n";
echo "<META name='keywords' lang='en-us' content='".$meta_keywords."' />"."\n";
echo "<META name='description' content='".$meta_description."' />"."\n";
echo "<META name='ROBOTS' content='".$meta_robots."' />"."\n"; // robots page directive
echo "<base href=".base_url()." />";

echo "<style type='text/css' media='all'>@import url('css/twpd.css');</style>"."\n";
echo "<link rel='stylesheet' type='text/css' media='all' href='css/twpd.css' />"."\n";

/* End of file ./application/views/twpd/page_header.php */

why on god's green earth are you echoing the meta tags using php????? what's wrong with you???? this drives me spare, when i see these types echo statements it makes me wanna barf. there are times and places to do this stuff, and in a view file is NOT imho the time to do this.

personally i think it looks cleaner and is just better written like this:

<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE><?php echo $html_title; ?></TITLE>
<META name="title" content="<?php echo $meta_title; ?>" />
<META http-equiv="expires" content="<?php echo $expires; ?>" />
<META http-equiv="pragma" content="<?php echo $pragma; ?>" />
<META name="author" content="<?php echo $meta_author; ?>" />
<META name="keywords" lang="en-us" content="<?php echo $meta_keywords; ?>" />
<META name="description" content="<?php echo $meta_description; ?>" />
<META name="ROBOTS" content="<?php echo $meta_robots; ?>" />
<base href="<?php echo base_url(); ?>" />

<link rel="stylesheet" type="text/css" media="all" href="css/twpd.css" />

sorry for the nit picking rant.

@Rolly1971. You are absolutely correct. View files should have as little php in them as to make the page functional. Loops, echoing variables, and conditional structures. If you are going to start echoing html you might as well have db access in the view as well.

Not only that, but concatenation takes longer to process, just echo the variable out directly!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.