Welcome Guest, Not a member yet? Register   Sign In
Customizing Title and Meta Tag for SEO
#1

[eluser]bob rock[/eluser]
Looking for the way to customize elements for SEO, I've replaced
Code:
<?php echo $title; ?>
but nothing happened. I haven't also found any advice about customization of meta tag descriptions. Thanks for any help. Ciao Bob
#2

[eluser]TWP Marketing[/eluser]
It's not completely clear what you are asking for. Actual SEO is somewhat outside the spec of this forum. If you want to know how to code your meta data, using CI and PHP, that is a relatively simple task.

In your example, you show a var named $title, which I assume holds the meta title string. I use this format in the html head section:

Code:
...
echo "<META name='title' content='".$meta_title."' />"."\n";
...

Similar code works for any type of meta tag, however the actual content of the php var depends on the website content. For that, I suggest doing the proverbial search on "SEO" and looking for techniques and advice on how to optimize. The amount of available information is huge. You can also look for forums whose specific purpose is SEO discussion

Hope this helps, but feel free to ask again if I misinterpret your question
#3

[eluser]bob rock[/eluser]
[quote author="TWP Marketing" date="1342391991"]It's not completely clear what you are asking for. Actual SEO is somewhat outside the spec of this forum. If you want to know how to code your meta data, using CI and PHP, that is a relatively simple task.

In your example, you show a var named $title, which I assume holds the meta title string. I use this format in the html head section:

Code:
...
echo "<META name='title' content='".$meta_title."' />"."\n";
...

Similar code works for any type of meta tag, however the actual content of the php var depends on the website content. For that, I suggest doing the proverbial search on "SEO" and looking for techniques and advice on how to optimize. The amount of available information is huge. You can also look for forums whose specific purpose is SEO discussion

Hope this helps, but feel free to ask again if I misinterpret your question[/quote]

Hi, many thanks for your reply. My purpose is to customize Title and Meta Tag for every page. I do this for SEO. I'm poor in skills in php and it's the first time I have seen CI.

If I've well understood I should try with your code

Code:
echo "<META name='title' content='".$meta_title."' />"."\n";

where should I put my title here before?


And for the meta tag "content" should i use this code?

Code:
echo "<META name='content' content='".$meta_content."' />"."\n";

Where should I inserted here the content?

I'm sorry if these are very basic questions. Thanks and ciao. Roberto
#4

[eluser]CroNiX[/eluser]
I would start with reading the user guide.

This page answers these questions.
#5

[eluser]TWP Marketing[/eluser]
Bob I set the content of the meta tags in my controller functions. I have one view field which is used for all pages and the content of each meta element is set in that controller, depending on which page is needed. The is that view:
Code:
<?php
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 */
In the controller I set a default value for each meta element and then override any elements which are needed for a particular page

Controller:
Code:
...These are default values
public function load_html_view_data()
{
   // set html header defaults
  $this->view_data['html_title']       = $this->view_data['page_name'].'- TWP Marketing™ - Goods, Services and Advice';
  $this->view_data['expires']          = "-1";
  $this->view_data['pragma']           = "no-cache";
  $this->view_data['meta_title']       = "Goods, Services and Advice";
  $this->view_data['meta_author']      = "TWP Marketing™";
  $this->view_data['meta_keywords']    = "";
  $this->view_data['meta_description'] = "TWP Marketing™ - Goods, Services and Advice";
  $this->view_data['shortcut_icon']    = '<link rel="shortcut icon" href="http://twpmarketing.com/favicon.ico" type="image/x-icon">';
  return;
}
...


For a specific page, I overwrite a few of the meta elements, for example in my page on SEO information, this is the code which sets the meta elements:
Code:
...
public function seo()
{
   // set page name
  $this->view_data['page_name'] = 'seo';

   // load advertising for side panel
  $this->view_data['ad_list'] = $this->load->view('ad_list',$this->view_data,TRUE);

   // get data specific to page_name
  $this->load_html_view_data();

[b]   // override default view data
  $this->view_data['meta_keywords']    = 'TWP Marketing™, Search Engine Optimization, seo';
  $this->view_data['meta_description'] = 'Search Engine Optimization';
  $this->view_data['meta_title']       = "Search Engine Optimization";
  $this->view_data['meta_robots']      = $this->view_data['all_robots'];[/b]

   //load views into data array
  $data = $this->load_template_views();

   // create page html and send to browser for display
  $this->load->view('page_template', $data);
  return;
}
...

Does this answer your question? There are many other ways to approach this.
#6

[eluser]bob rock[/eluser]
Hi TWP,

I've tried to follow your road. I'm not a developer so I would try to be faster as possibile using some of your code, so I've made this file called page_header.php in views folder


Code:
<?php
echo "<TITLE>".$html_title."</TITLE>"."\n";
echo "<META name='title' content='".$meta_title."' />"."\n";
echo "<META name='description' content='".$meta_description."' />"."\n";
/* End of file ./application/views/twpd/page_header.php */


Then I've made this file called page_header.php in controllers folder




Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class page_header extends CI_Controller {

public function load_html_view_data()
{
   // set html header defaults
   $this->view_data['html_title']       = $this->view_data['page_name'].'- Casa Vacanze Antico Borgo Casalappi';
  $this->view_data['meta_title']       = "Antico Borgo Casalappi";
  $this->view_data['meta_description'] = "Casa Vacanze a 6km dal mare, appartamenti in stile toscano, piscina, tennis, giochi - Campiglia Marittima - Toscana";
  return;
}


I'm not able to put the third piece of code because I haven't found any "public function ()" in php files in views folder in which I could make my last customizations for every page. In fact I would have liked to put this code


Code:
...
public function seo()
{
   // get data specific to page_name
  $this->load_html_view_data();

[b]   // override default view data
  $this->view_data['meta_description'] = 'Here there will be my description for every page';
  $this->view_data['meta_title']       = "Here there will be my title for every page";

   //load views into data array
  $data = $this->load_template_views();

   // create page html and send to browser for display
  $this->load->view('page_template', $data);
  return;
}
...
[/quote]

But I don't know if I have made some other mistakes and where I should put it.

Thanks and ciao
#7

[eluser]TWP Marketing[/eluser]
Ok, We are getting very deep into code and I suspect you are not up to speed with MVC and the CI framework.
What you did with my function, turning it into a controller by itself, WILL NOT WORK.

You need a controller file which would contain your functions. You will not find them in the CI core files. Before you jump in deep water, please try making a simple website like the example code in the User Guide. If you already have a site coded in PHP (not using the CI framework) then you will need to learn CI first, before you try to move your code into the framework. It isn't terribly difficult, but there is a learning curve which we all have to go through.

Start with a simple MVC site. One controller, maybe a model if you have a database and some views.\

Go to the User Guide and look for the tutorial in the index. Build that small application.
#8

[eluser]boltsabre[/eluser]
On a SEO side note, you can just plain forget about about the meta 'title' (not to be confused with the <title></title> tag) and meta 'keyword' tags.

Google doesn't use 'keywords' at all, for anything, but bing has stated that they actively use them to search for spam/keyword stuffing and to demote sites. As such the only thing a 'keyword' tag can do for you (in regards to the big search engines/99.9% of searches) is potentially harm your rankings.

Google has also stated that if you have a <title></title> tag they don't use the meta 'title' tag for improving rankings, however, it is possible that they may use it for a flag for spam if it is keyword stuffed. So again, it is redundant, and so long as you have a <title></title> tag about the only thing it is likely to do is to be used to detect keyword stuffing and potentially demote your site.

A few bytes less of html for the server to transmit and the browser to interpret/render, a few less lines of php code for the server php interpreter to handle, and two less php variables committed to memory on each page load. Tiny tiny savings in the larger scheme of things, but every little bit helps!
#9

[eluser]bob rock[/eluser]
Thanks to you all for your replies, but I believe it would have been not so difficult to insert a Title (tag<TITLE>..............</TITLE&gtWink and a meta tag description (<META NAME="DESCRIPTION" CONTENT=".............................">in a page.

This website has been developed from some programmers, I'm only involved in web marketing tasks and these actions are often very common and basic.

With this framework it seems to build a house (I should have not time to reduce my learning curve), when it takes 2 minutes in html or php files.

Any other way to do this?

Thanks and ciao
Bob
#10

[eluser]Aken[/eluser]
There's lot of different ways to do it. We can't tell you which is best for you without knowing your situation. I'd suggest hiring a developer to help you directly if you don't understand PHP.




Theme © iAndrew 2016 - Forum software by © MyBB