#1
  1. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Jan 2005
    Posts
    10
    Rep Power
    0

    Generating page titles with PHP


    Hi Guys

    I am new to PHP and am trying to generate suitable page titles for the pages created.

    My pages are made using a block of PHP contained within the HTML.

    I have tried the following two methods:

    1. The head section contained in the html before the PHP, with the title removed from the head and placed in the php.

    2. The entire head section placed within the PHP, which follows the body tag.

    Both methods seem to display the page perfectly well, but would search engines have an issue with the title not being within the head section or with the head section being after the start of the body?

    Is there a more suitable method?

    Any tips would be greatly appreciated.
  2. #2
  3. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Mar 2005
    Location
    Denmark
    Posts
    137
    Rep Power
    15
    Originally Posted by Srivvy
    Hi Guys

    I am new to PHP and am trying to generate suitable page titles for the pages created.

    My pages are made using a block of PHP contained within the HTML.

    I have tried the following two methods:

    1. The head section contained in the html before the PHP, with the title removed from the head and placed in the php.

    2. The entire head section placed within the PHP, which follows the body tag.

    Both methods seem to display the page perfectly well, but would search engines have an issue with the title not being within the head section or with the head section being after the start of the body?

    Is there a more suitable method?

    Any tips would be greatly appreciated.
    I use this:

    <php
    generate title, description, keywords
    ?>

    <head>
    <title><?php echo $title;?></title>
    ...
    ...
    ...
    </head>

    Works perfectly
  4. #3
  5. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Jan 2005
    Posts
    10
    Rep Power
    0
    Thank you very much squize

    I will try this out tonight and will let you know how it goes.

    Srivvy
  6. #4
  7. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Sep 2005
    Posts
    143
    Rep Power
    14
    Search engines only have an issue with badly formed HTML, they neither know nor care about your PHP code. So you can do things pretty much any way you like as long as well formed HTML is the result.
  8. #5
  9. Croatia - Hrvatska
    SEO Chat Skiller (1500 - 1999 posts)

    Join Date
    May 2005
    Location
    Croatia - Hrvatska
    Posts
    1,891
    Rep Power
    18
    Search engines only have an issue with badly formed HTML, they neither know nor care about your PHP code. So you can do things pretty much any way you like as long as well formed HTML is the result.
    SE can't see php code becose is executed on server and html is always results of php code

    squize got 1 option, but i use rows in database for title and metas to get full control when i want
  10. #6
  11. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Apr 2005
    Location
    Durham, NC
    Posts
    386
    Rep Power
    15

    Page titles as filenames...


    A lot of my sites do this...

    Filename:
    san-diego-mortgages.php

    PHP Code:

    $thisfile 
    $_SERVER['PHP_SELF'];
    $thisfile str_replace('.php','',$thisfile);
    $thisfile str_replace('-',' ',$thisfile);
    $keyarray explode('/',$thisfile);
    $size count($keyarray)-1;
    $keyword $keyarray[$size];
    $title ucwords($keyword); 
    and then

    PHP Code:
    <title><? echo $title?></title>
    that way I can pass the title as the url. give me seo friendly file names and titles

Similar Threads

  1. Page Title over-optimization penalty
    By TaoMax in forum Google Optimization
    Replies: 4
    Last Post: Jun 10th, 2005, 07:51 AM
  2. Replies: 5
    Last Post: Apr 23rd, 2005, 11:09 AM
  3. My 100th post
    By craige in forum Search Engine Optimization
    Replies: 7
    Last Post: Jan 6th, 2005, 03:12 AM

IMN logo majestic logo threadwatch logo seochat tools logo