Jump to content

General website architecture?


j3n

Recommended Posts

Hey,

 

Out of curiosity, what is the most common general trend of website architecture?  i.e. If I have a layout whereby there is a border, links and a background that are the same no matter what content is being displayed (home, about us, services.. etc all show up within the same border), should I copy and paste my code for home.html in each page, services.html.. etc, changing only the content?  Or is there a more efficient way of going about this?

 

At the moment, my site has one main page with a div that loads various content using an ajax pagerequest script.  It was pointed out to me by a couple members here that that kills my SEO.  So, now that I see the light, how am I to fix this?

 

Any thoughts?

 

Thanks!

Link to comment
Share on other sites

If it's many pages the smart thing to do would be to use a database for the content itself.

If it's a small site you can make do with PHP includes.

 

If you do not have access to a server side scripting language then yeah, copy pasting. Do keep all styling in a stylesheet though! So when you want to change the design you need to update ONE stylesheet as opposed to many HTML files.

 

And yes, ajax will kill your SEO.. you simply have to have mindset. Disable javascript in your browser and see what you can still access, that will pretty much be the same as search engines can.

So if you made something rely on javascript to be enabled a search engine wont index it, simple as that.

 

[edit]

Think there are some editors offering templating options as well, though I have 0 experience with that myself.. just letting you know the option is out there somewhere.

Link to comment
Share on other sites

And yes, ajax will kill your SEO.. you simply have to have mindset. Disable javascript in your browser and see what you can still access, that will pretty much be the same as search engines can.

So if you made something rely on javascript to be enabled a search engine wont index it, simple as that.

I type gibberish at times.

 

Anyhow, if you want search engines to find your content you have to avoid relying on javascript and/or flash to get to the content. Search engines don't understand it (that statement isn't entirely true btw) and thus can't find it.

A nice way of giving a better idea what is and what isn't accessible is by using a browser that supports not much more than just html, such as lynx

Link to comment
Share on other sites

  • 2 weeks later...

if you use php you could use a switch statement.

 

heres the one i use

 

header

<?php
$nav = $_GET['action'];
secure($nav);
?>

 

body

<?php
                //Use a switch statement to go through the URLS.
                switch ($nav) {
                    case "login":
                        include ('login.php');
                        break;

                    case "logout":
                        include ('logout.php');
                        break;

                    case "editprofile":
                        include ('editprofile.php');
                        break;

                    case "memberlist":
                        include ('memberlist.php');
                        break;

                    case "register":
                        include ('register.php');
                        break;

                    case "viewterms";
                        include ('terms.php');
                        break;

                    case "forgot";
                        include ('reset_pw.php');
                        break;

                    case "profile";
                        include ('profile.php');
                        break;
				   
			    case "dl";
                       include ('download.php');
                       break;
				   
			    case "game";
                       include ('game.php');
                       break;
				   
				case "review";
                       include ('review.php');
                       break;
				   
				case "video";
                       include ('video.php');
                       break;
				   
				case "about";
                       include ('about.php');
                       break;
				   
				case "contact";
                       include ('contact.php');
                       break;


                    default:
                        include ('default.php');
                        break;



                }

                ?>

 

this code sets what page is displayed by default

 

 
default:
          include ('default.php');
          break;

 

that also formats your urls like this.

 

index.php?action=contact

 

 

i know the code is long but i like it a lot

Link to comment
Share on other sites

neat.

 

do you include() the content in the middle of your container page code? i.e.

 

index.html:

 

<html>

<body>

 

include()

 

</body>

</html>

 

if so, isn't this detrimental to SEO?

 

 

Otherwise, how is this different than just using plain <a href>? 

 

 

Link to comment
Share on other sites

the way i might go about this is in every page have something like the following

 

on index.php

<?php
include('header_information.php');
//this file might open a div element in html
?>
My Pages Content Heree.....
<?php
//this include would close that element
include('footer_information.php');
?>

 

my header_information.php

<html>
<head>
</head>
<body>
<div>

 

my footer_information.php

</div>
</body>
</html>

 

 

and so my output page would contain something like...

 

<html>
<head>
</head>
<body>
<div>
My Pages Content Heree.....
</div>
</body>
</html>

 

this way would allow you to change the look and feel of your site alot better since all the styles/layout elements would be in one file. You would also use an include inside of one of your other files like your "header_information.php" possibly containing a side menu...its all up to you, but in the future It would become easier to reposition an element, it would only have to be done in one place you wouldn't have to go into every single file....

Link to comment
Share on other sites

If it's many pages the smart thing to do would be to use a database for the content itself.

If it's a small site you can make do with PHP includes.

 

Database? Why would you put an extra strain on the database through files that rarely change? How would you even store the text files anyway? Blob? That's a great way to destroy optimization in mysql!

 

Includes/requires are fine for the most part. Even large sites use them! However, once your website gets HUGE you may consider going into a templating system or make your own. This enables you to separate php from html (to some extent). This is called MVC.

Link to comment
Share on other sites

should I copy and paste my code for home.html in each page, services.html.. etc, changing only the content?

If it's many pages the smart thing to do would be to use a database for the content itself.

If it's a small site you can make do with PHP includes.

 

Database? Why would you put an extra strain on the database through files that rarely change? How would you even store the text files anyway? Blob? That's a great way to destroy optimization in mysql!

*scratches head*

No idea where you're getting the text files from all of a sudden and why a blob database type would be useful.

 

Back to j3n. What system do you have in place atm. I see you got urls like portfolio.php. So I assume you're including the header/footer on every page.

For the switch to work you'd need to do something like /?page=portfolio, then you can use something like this in the index.php.

if( isset( $_GET['page'] ) ) 
{
  switch( $_GET['page'] ) 
  {
    case 'portfolio':
      include( 'portfolio.php' );
      break;
    case 'services':
      include( 'services.php' );
      break;
  }
}
else {
  include( 'homepage.php' );
}

Of course if you always got the parameter in the url (the ?page=thisIsTheParameter) exactly matching the filename like in gfadmin's example you could do the following as well:

if( isset( $_GET['page'] ) ) 
{
  switch( $_GET['page'] ) 
  {
    case 'portfolio':
    case 'services': //simply add "case 'content':" and that will work for contact.php  
      include( $_GET['page'].'.php' ); //$_GET['page'] is the text of the case.
      break;
  }
}
else {
  include( 'homepage.php' );
}

 

The disadvantage of this method is that you get urls with parameter in them, which search engines don't like all that much. (As search results etc would be indexed as well if it listed everything with a ? in the url). So you'll have to make use of mod_rewrite or use some other trick to reform urls to a search engine friendlier path like /portfolio.

Link to comment
Share on other sites

<?php
// http://www.domain.com?page=home      => home.php
// http://www.domain.com?page=contact   => contact.php
// http://www.domain.com?page=spywareintrusion => home.php
$allowed = array( 'home', 'contact', 'users', 'addresses' );
$inc_file = in_array( isset( $_GET['page'] ) ? $_GET['page'] : 'home', $allowed ) ? $_GET['page'] : 'home';
include( $inc_file );
?>

Link to comment
Share on other sites

on index.php

<?php
include('header_information.php');
//this file might open a div element in html
if( isset( $_GET['page'] ) ) 
{
  switch( $_GET['page'] ) 
  {
    case 'portfolio':
      include( 'portfolio.php' );
      break;
    case 'services':
      include( 'services.php' );
      break;
  }
}
else {
  include( 'homepage.php' );
}
//this include would close that element
include('footer_information.php');
?>

 

my header_information.php

<html>
<head>
</head>
<body>
<div>

 

my footer_information.php

</div>
</body>
</html>

 

 

and so my output page would contain something like...

 

<html>
<head>
</head>
<body>
<div>
My Pages Content Heree.....//decided by the if & switch statement contained in another file/database what ever it is...
</div>
</body>
</html>

Link to comment
Share on other sites

Instead of using an if/else statement and then a switch statement on top of that - simply use a switch statement with a default at the end to have the same functionality as the if/else statement. Waste of extra processing power.

You'll need to check if it's set anyhow as it is a bigger slow down letting it do "Notice: Undefined index:". On the same note the nested ternary operator in roopurt18's suggestion is even slower as it will always check all 'cases'. (not to mention the readability becomes quite poor, certainly to the untrained eye and I don't think j3n has that much experience with php (yet))

Then again all of this is barely a microsecond and only done ONCE per page.

 

Redirecting anything with a default case to your home page might hurt SEO rating due to duplicate content from what I've read although I haven't tested it myself and it seems odd it would unless someone starts spamming links around the internet with something like yoursite/?page=nonsense. Yields unexpected results anyhow, I'd use the default case for a 404 page (with the appropriate header) if anything.

 

gfadmins last post is what I meant, guess his example is a bit more clear.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.