Forum Moderators: coopster

Message Too Old, No Replies

Each page with its own <title>titles</title>

How can I do this when running php and $query_string

         

I Will Make It

11:03 pm on Feb 24, 2006 (gmt 0)

10+ Year Member



Hi there, I'm making a new site these days, and this site will eventually and hopefully consist of 100's of pages...
As I'm now figuring out how to best write the site regarding to the SEO subject, one of many things I've decided is that each page should have it's own title.

Now, I'm no expert in this area, so I need your guys help.. How can I use php to give each of the pages its own title?
So far I've only made pages in php / html that uses the same title as the index.php does, and this isn't exactly the best SEO i know of ;)

I would like the page to show only:

(examples)
www.mydomain.com/widgets.htm
with the title:
Widgets here, widgets there, widgets everywhere

and then

www.mydomain.com/widgets2.htm
with this title:
Cool widgets, nice widgets, fun widgets

when the urls would really be:
www.mydomain.com/index.php?site=widgets
and
www.mydomain.com/index.php?site=widgets2

Is this possible when I use a index.php looking something like this: (short version)

if(!QUERY_STRING) {
include "temp/top.tmp";
include "temp/main.tmp";
include "tmp/bot.tmp";
}

Oh.. and also, when converting query_strings from
www.mydomain.com/index.php?page=red
to
www.mydomain.com/red.htm,
so that users will see
www.mydomain.com/red.htm
- what will google see?

I'm terrible sorry for this long post, and the tons of questions, but I would be more than grateful for some guidelines on how to do this :)

I Will Make It

8:44 pm on Feb 25, 2006 (gmt 0)

10+ Year Member



hmm.. no one?

jatar_k

9:01 pm on Feb 25, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



strangely I was just getting to this as you bumped ;)

takes a bit to answer when there are lots of questions.

for the part about changing the url that appears to the user you will need to look into using mod_rewrite. We have a primer available from the apache forum
Mod_Rewrite Beginning [webmasterworld.com]
there are also a couple of other threads in the Apache forum library [webmasterworld.com]

>> - what will google see?
google sees the same thing as users see, your rewritten url

as far as the templating goes there are a couple ways of doing it. Using the query string, as in your example, is very possible. You would probably use $_SERVER['HTTP_REFERER'] and then have to pull the keywords out of that. From there you could do your title accordingly.

I am not the biggest fan of this method, even though I have employed it. You are better off haveing a title targetted to the content of each specific page.

This looks like it would be a database driven site, if that is the case then you can have an extra column in your database that stores your title for the page and pull that along with the content.

If it isn't db driven and you actually have content in each file which goes through a template then you just add another var in your template and set it in each file before the template is called.

I Will Make It

9:27 pm on Feb 25, 2006 (gmt 0)

10+ Year Member



AHA! Thank you :D
Even though I'm not actually a newbie to programming, I'm not even close to be where I want to be when it comes to write php. I have been thinking that it would be nice to run the page through a DB, and since you mentioned it, I think I'll have to try!

The only thing that concerns me if I use a DB: Wouldn't I also want to (have to?) write a kind of a admin page where I easily can add the content to each different page.. Like the title, articles, outgoing links for that special page and so on..?
Or would I be better of doing this just using phpMyAdmin or MySqlfront. I am a noob when it comes to setting up db's, and using my head to put it up the way I would benefit from when I develop the page; Like what kind of fields I should put in what kind of different tables..

But anyways.. Thank you for some great answers, now I'll go and try to study some DB examples ;)

jatar_k

9:44 pm on Feb 25, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



yes you would need an admin page/section

you don't need to rush out and switch to db, I was just looking at the query string examples and assumed. Another thread that might help from the PHP library [webmasterworld.com]

A dynamic site in 2 minutes [webmasterworld.com]

that might give you some ideas.

and also, with all the sites I have done I have never used db driven content through a template, I don't like it.

I Will Make It

10:13 pm on Feb 25, 2006 (gmt 0)

10+ Year Member



One more thing.. I'm really starting to feel hot and fantastic love for WW forums.. Thank you!?
That link to the "dynamic site making" post really helped me a lot!

Phew.. I don't think i need the stupid database ;)