|
|
|
04-14-2008, 02:17 PM
|
Postid: 166955
|
|
Site Owner
Forum Notability:
1175 pts: A True Crowd-pleaser!
[ Post Feedback]
Join Date: Feb 2005
Location: Connecticut
Posts: 719
|
Re: Value of links in SEO
It's not as hard as you may think.
First, you'll have to separate out the common parts of your index.php file to make the common include files. Then change the menu links from <a href="?act=14"> to <a href="donations.php">.
Since you've already got your content in separate files, you just have to add the same stuff before and after the existing body content. This could be done with a Perl,PHP or shell script - or you could even use the template feature of Dreamweaver to update all the files at once.
Then you'll just have to go in and give each file a unique title, keywords and description - which you were going to do anyway.
The way you have it now, all your pages have the same title, description and keywords, because those are in the <head> element which is in the common index.php file. The code you tried from George didn't work because you can't change the page title in the <body> section.
|
|
|
04-14-2008, 03:45 PM
|
Postid: 166957
|
|
Registered User
Join Date: Nov 2007
Posts: 50
|
Re: Value of links in SEO
I agree that separating them out is not as hard as you think, but if you choose not to do that, I believe it is also pretty easy to do what you want using the same structure.
First, to get this exactly right, you will need someone better at this than me, but I will give a starting point of what I believe would work.
1. In the index file, move the three lines we're referring to here to the bottom of your header (title, meta tags, meta description.)
2. Move up your php header marker "< ? " above those three meta tags, so the header information now becomes php, not html. Change the lines from as they are to echo 'this line here';
3. You might need to globally declare three values
Code:
global $title, $metatags, $metadesc;
4. In place of your current title, meta tags and meta description, it would be changed to something like this.
Code:
echo '<title>' . $title . '</title>' . "\n";
echo '<meta name=\"KEYWORDS\" content=\"' . $metatags . "\n";
echo '<meta name=\"DESCRIPTION\" content=\"' . $metadesc . "\n";
5. For each content page add these lines at the top of the php code
$title = 'Unique Title for this page';
$metags= 'Unique, meta tags, for, this, page';
$metadesc= 'Unique meta description for this particular page';
Once that is done, the defined variables listed on each content page should pass to the header variable and display properly in the output.
Like I've mentioned earlier - There is very little chance this will work correctly exactly as I've written it. I'm certain I am missing some quotes in certain places and I don't think I've "echoed" the lines quite properly - without trial and error, I can never quite figure out when to add a string continuation period and when not to - but someone who knows what there doing can take this and make it work properly. I believe the content is correct, it will just need some syntax tweaking...
|
|
|
04-14-2008, 05:09 PM
|
Postid: 166958
|
|
Site Owner
Forum Notability:
1175 pts: A True Crowd-pleaser!
[ Post Feedback]
Join Date: Feb 2005
Location: Connecticut
Posts: 719
|
Re: Value of links in SEO
Unfortunately, the body content pages are included after the title and meta tags have been sent off to the user's browser. Unless you're in a function, changing a variable value further down the page won't effect code above it.
bar.php:
PHP Code:
<?
$title="hello from bar.php";
?>
foo.php:
PHP Code:
<html>
<body>
<pre>
<? global $title; ?>
Before include, title='<?= $title ?>'
<? require "bar.php"; ?>
After include, title='<?= $title ?>'
</pre>
</body>
</html>
When you view foo.php in a browser, you get:
Quote:
Before include, title=''
After include, title='hello from bar.php'
|
|
|
|
04-14-2008, 06:25 PM
|
Postid: 166959
|
|
Registered User
Join Date: Nov 2007
Posts: 50
|
Re: Value of links in SEO
That's unfortunate. I have multiple includes in my setup, but it appeared that the variables were defined after the header info was sent. I was assuming everything was created server side, then sent to the browser at the end.
So, I don't suppose there is a way to send these out of order? Create a string of header info as one variable, then echo that at the end?
So, is there no way to do this without breaking up the sections into multiple files?
|
|
|
04-14-2008, 08:21 PM
|
Postid: 166960
|
|
Site Owner
Forum Notability:
1175 pts: A True Crowd-pleaser!
[ Post Feedback]
Join Date: Feb 2005
Location: Connecticut
Posts: 719
|
Re: Value of links in SEO
Quote:
|
I was assuming everything was created server side, then sent to the browser at the end.
|
That's more-or-less how it is, but the file gets processed from top to bottom, once.
Quote:
|
So, is there no way to do this without breaking up the sections into multiple files?
|
You could make one include file which has a different function to output each section...
common.php:
PHP Code:
<? function common_head() { ?>
<style type="text/css">
<!--
[common CSS stuff]
-->
</style>
<script type="text/JavaScript">
<!--
[common javascript stuff]
-->
</script>
<? } // end of common_head() ?>
<? function common_body_top() { ?>
<div id="page_header">
[common graphics, menus, etc.]
</div>
<? } // end of common_body_top() ?>
<? function common_body_bottom() { ?>
<div id="page_footer">
[footer stuff]
</div>
<? } // end of common_body_bottom() ?>
Then my sample file from a few posts back becomes:
PHP Code:
<? require ("./common.php") ?>
<html>
<head>
<title>unique title of page</title>
<meta ... other stuff unique to this page />
<? common_head() ?>
</head>
<body>
<? common_body_top() ?>
<div>
unique page content goes here
</div>
<? common_body_bottom() ?>
</body>
</html>
There's only one file to include, and a few function calls.
I'm not sure if that'll help, but I happen to be converting a Dreamweaver template-based site to use php includes, so it's what I'm thinking about right now...
|
|
|
04-16-2008, 04:10 PM
|
Postid: 167017
|
|
Site Owner
Forum Notability:
169 pts: Ambassador of Goodwill
[ Post Feedback]
Join Date: Mar 2006
Location: Czech Republic mostly
Posts: 514
|
Re: Value of links in SEO
I had to go off for some other work and have a bit of a lay-down after reading these remarks and some other forums on this topic
Trying to understand some principles here.
-- If you would make an include file at the complete beginning of the index.php, with a for each important page a separate page title and description, how would google crawl this? Would that bot just run through the different title-description combo's until it reached one that fits its query, and then display that as result?
Simple put (no effort on coding, just principle):
Include file:
page1 $title1=nice & $descr=also nice
page2 $title2=good & $descr=better
page0 $title=default & $descr=default
page 0 covering intro and pages 3-x
end file
If the bot thinks page 2 matches the query best, it will display that title and description with a link to page 2?
-- The first time our page gets loaded in a browser with the default title and description. When clicking a link to go to the next page, does the whole stuff get loaded from the top again or is the head stuff cached and only the body content switches?
-- Is it not possible to take the <title> part out of the header and put it completely at the bottom of the whole process?
|
|
|
04-16-2008, 04:32 PM
|
Postid: 167021
|
|
Registered User
Join Date: Nov 2007
Posts: 50
|
Re: Value of links in SEO
Tom can better answer most of these questions better than I can, but here goes...
Quote:
|
how would google crawl this
|
Search engines see what a person viewing a page would see, so now matter how it works on the backend, if Internet Explorer shows unique titles and meta tags for each page, that's what Google will see. Just look at the page source after it's loaded into a browser - it all shows up as html, and that what's being crawled.
Quote:
|
When clicking a link to go to the next page, does the whole stuff get loaded from the top again or is the head stuff cached and only the body content switches
|
Each page is loaded from scratch each time - there is no content caching. Now, the browser caches images and that good stuff, but as far as the text, it will be created new each time.
Quote:
|
Is it not possible to take the <title> part out of the header and put it completely at the bottom of the whole process?
|
I don't know - The title must remain in the header, but I thought the header could be sent to the browser at the end. I have some files that appear to do this, but who knows - I've already been proven wrong on some PHP basics, so I'll leave the real answer to Tom or someone else.
But, I believe that all of the header information could be pulled out of the index page and placed in a header.php file. The variables as mentioned above go into each content page, the the header file is simply included in the index page. This way the variables get placed in the right order and everything is displayed correctly, right?
|
|
|
04-16-2008, 05:02 PM
|
Postid: 167024
|
|
Site Owner
Forum Notability:
169 pts: Ambassador of Goodwill
[ Post Feedback]
Join Date: Mar 2006
Location: Czech Republic mostly
Posts: 514
|
Re: Value of links in SEO
Quote:
Originally Posted by happety
Each page is loaded from scratch each time - there is no content caching. Now, the browser caches images and that good stuff, but as far as the text, it will be created new each time.
|
Just a quick reply before I am off to bed early for once (it's 11 pm here now, last night I was working on this till about 2 AM).
So let's assume a visitor starts on the main page with default title and description. He/she clicks on a link to the next page. In that case, the "$Get" function of the link from the intro page is acting BEFORE the head and title of the next page is reloaded. If so, it should be possible to write a routine in the <?php section to tell the site that, when reloading after clicking on ?act=x, title in header should echo the page title mentioned as part of ?act=x. And/or in the beginning of the index.php that, if a link is coming in for page ?act=x, title in header should echo the page title mentioned as part of ?act=x. Correct or am I getting too tired and confused already? 
|
|
|
04-16-2008, 10:01 PM
|
Postid: 167045
|
|
Site Owner
Forum Notability:
1175 pts: A True Crowd-pleaser!
[ Post Feedback]
Join Date: Feb 2005
Location: Connecticut
Posts: 719
|
Re: Value of links in SEO
Exactly.
How about something like this:
PHP Code:
<?php
// associate 'act' values with titles and content files
$act_values = array(
"home" => array("title" => "Home Page", "body" => "intro.php"),
"404" => array("title" => "Page Not Found", "body" => "404.php"),
"14" => array("title" => "Donations", "body" => "donations.php"),
"11" => array("title" => "Contact Us", "body" => "contact.php"),
// etc.
);
// default to home page if act not set
$act = "home";
// get act value and set to "404" if it doesn't match a valid page
if (isset($_GET["act"]))
{
$act = trim($_GET["act"]);
if (! isset($act_values[$act]))
{ $act = "404"; }
}
// set the title and content file to use below
$page_title = htmlspecialchars($act_values[$act]["title"]);
$page_body = $act_values[$act]["body"];
?>
<html>
<head>
<title><?= $page_title ?></title>
</head>
<body>
<?
// this replaces your entire switch statement
require $page_body;
?>
</body>
That's one way to make different parts of the page (title and body) dependent on a single parameter.
-
I hate to open this can of worms, but you can use mod_rewrite to make it look like your single index.php file is really separate pages. For example, set up a rule that rewrites "yourdomain.com/Donations" to "yourdomain.com/index.php?act=14" (and don't forget to change all your links). A browser or bot will only see the "/Donations" URL and won't know that the page they get really comes from index.php.
You can search these forums or the Apache docs for mod_rewrite to get examples. Be careful though, it's not for the faint of heart. You can break your entire site, so test it first in a hidden directory until you get the bugs worked out.
-- Tom (also  )
|
|
|
04-16-2008, 10:19 PM
|
Postid: 167047
|
|
Registered User
Join Date: Apr 2002
Location: San Antonio, Texas
Posts: 7,204
|
Re: Value of links in SEO
Quote:
|
A browser or bot will only see the "/Donations" URL and won't know that the page they get really comes from index.php.
|
I don't know how it's done or if it is true of all redirects but googlebot can sniff out at least some redirects made using .htaccess and if it smells fishy they may apply a penalty even though a penalty is not deserved.
I am not trying to spread FUD here, I would like some clarification myself. I have been warned about redirects at my Google Webmaster Dashboard even though it was (I thought) an innocent application of them and no deception was intended.
In fact the whole thing began because Google was wrongly applying secret penalties in the first place. Yes, I'm certain of that.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 12:24 AM.
|
| |
|
|
|