• # September 18, 2011 at 12:33 am

    I would steer clear of this method and just suck it up. Because you can not possibly have that many pages. If you do, this the way you are talking about it will both kill your SEO and the scalability of any site. These two reasons alone make the cost out-way the benefits. You will also learn a lot more by doing the project in a more scalable manner.

    # September 18, 2011 at 12:57 am

    This reply has been reported for inappropriate content.

    Well thank you. I appreciate your response, and will take act upon it and keep what I have.

    one question though, when I’m using the include header, and footer, (mainly header) how do i do Nav highlight, and change the title depending on the page the user is on? because right now i have no way of telling my TITLE tag where the user is

    # September 18, 2011 at 5:49 am

    get the url
    remove php extension so you have: home, about, contact
    echo that to a body class

    In your css target the body class with a current class to your nav item

    I’m not sure I explained that well. I think you should stick to WordPress, man. Atleast until you get the hang of how to loop your content.

    @seanroberts – I’m not aware of how a loop will “kill” your SEO, care to explain?

    # September 18, 2011 at 11:31 am

    never trust user input. something like


    is evil itself.

    now, if you don’t want to “echo the whole page”, don’t use include(), just use file_get_contents(), and *echo that. that also means you can use an .html extension, which might help with text editor syntax highlighting, too.

    (* what I personally do is build the whole output, then set the appropriate headers, then have a single echo $output; at the very end)

    if you want to use a whitelist:

    // do stuff

    if (in_array($_GET, array('home', 'about', 'another_page', 'you_get_the_idea')))
    $page = file_get_contents('path_to_pages/' . $_GET . '.html');
    $page = '404 sadface.';

    // do stuff

    that is the one super secure way — nothing you haven’t predetermined to be a valid argument gets accepted.

    I guess you could also remove all dots and slashes from $_GET, and then do a

    if (file_exists('path_to_pages/' . $_GET))

    instead of the in_array() check, that *should* be safe, too, but maybe there is more to watch out for than dots and slashes I’m not sure, I’m usually using the a database anyway, and when I don’t I usually use a white list because hey, it’s not *that* much hassle and it’s bulletproof.

    as long as it’s your own little site, go for it… you can always “just use wordpress” later. yes, if you want good results fast, use wordpress :P and if you do it your own way, you will eat your foot so many ways! it’s amazing what one can screw up (there’s more to HTTP than just echoing stuff, if you want things properly cached, support 304 not modified and whatnot), and you’ll be fixing errors and wait months for google to forgive you haha… but I say, go for it. learn how this stuff actually works.

    everybody should have built at least one crappy little CMS before using those of others, that’s my motto :P

    # September 18, 2011 at 11:36 am

    one thing that’s really important, set the right headers! and generally learn about the awesome extra stuff you can do with them, starting with the basics of setting a content-length that matches the length of the string you’re going to output, working yourself up to caching, etags and 304 not modified :D

    but one thing is sure, if you don’t set a 404 header when outputting a 404 page, search engines will hate you. that’s the one thing about headers you *have* to learn. been there, done that ^^

    # September 18, 2011 at 1:20 pm

    This reply has been reported for inappropriate content.

    when using

    if (in_array($_GET, array('home', 'about', 'another_page', 'you_get_the_idea')))
    $page = file_get_contents('path_to_pages/' . $_GET . '.html');
    $page = '404 sadface.';

    does that mean i should be making an index file. with a header and footer inside there and just using the above code on the index for main-content?

    and wont need to include my header and footer?

    # September 18, 2011 at 1:48 pm

    This reply has been reported for inappropriate content.

    okay. so the first pahe shows the header and footer, but no content.

    when i go to other pages, it just shows the stripped down version of the page, no header, footer, it stripps the styling aswell. ? what am i doing wrong?

    (i removed header and footer of all pages.)
    made my index page the one to work off of. here’s an example:
    instead of the example ill show you what im using exactly.

    Attila Hajzer Website Design Portfolio

    Attila Hajzer

    Web Design Portfolio


    if (in_array($_GET, array('home', 'about', 'services', 'portfolio' , 'resume' , 'skills')))
    $page = file_get_contents('/' . $_GET . '.php');
    $page = '404 sadface.';


    google_ad_client = "ca-pub-8898760799249402";
    /* Website Footer */
    google_ad_slot = "1709532676";
    google_ad_width = 234;
    google_ad_height = 60;

    <script type="text/javascript"

    here’s the link to the website

    # September 18, 2011 at 2:05 pm

    please try to understand what the code actually does :)

    it is reading the file, and assigning the content to a variable ($page) — but unless you echo that variable, of course nothing will show up! I just like to put stuff in a variable first, because then you can do more with it than just echo it.. but in this case that’s unnecessary I guess. sorry for the confusion ^^

    # September 18, 2011 at 2:11 pm

    This reply has been reported for inappropriate content.

    oh. my bad. lol well back to the drawling board.

    # September 18, 2011 at 9:54 pm

    This reply has been reported for inappropriate content.
    its solved. but thank you everyone.

    # September 20, 2011 at 10:17 am

    To be honest, the way you do it with the includes, that’s how I do it – except i use the require(); function.

    < ?php //header.php

    //if i'm using mysql:
    require('mysqlstuff.php') // this requires functions i made for accessing mysql databases

    //set title dynamically
    if(isset($title)) $title=$title;
    else $title="My Page Title";

    //start document
    print < << END
    < !DOCTYPE html>



    < ?php // index.php
    session_start(); // start session if needed

    //set title
    $title="Different title from the default one in header.php";

    print < << END


    require('footer.html'); // or footer.php depending on the type of code in the file

    # September 21, 2011 at 2:28 pm


    There is a way to make it SEO friendly and I was assuming how he was talking about doing the page is not good for SEO. If you create the header information (Meta data, Title, etc.), or have a function that adds information to the page based on the current page. However, I assumed he would not do that and just use the current page to build the actual page content. And here is where he confirms my assumptions. Doing the page this way will cause duplicate page titles, descriptions, etc.

    # September 21, 2011 at 2:44 pm

    Why are you so adamant on not using the includes or requires? This is what I do.

    I use variables for things that need to be page specific, like title and desc tags. This is an example of a drummed down version of what I typically do for small static sites.


    < !doctype html>

    < ?php echo $thisTitle; ?>


    < ?php
    $thisTitle='This is the title you change for each page';
    $thisDescription='This is the desc you change for each page';
    include ('html/header.php');

    < ?php include ('html/footer.php'); ?>

    # September 23, 2011 at 9:58 pm

    so you do want to rewrite your header and footer includes on each page. Well, use Ajax ! It’s bad for SEO but good for the soul. just kidding…

    # September 24, 2011 at 12:31 am

    This reply has been reported for inappropriate content.

    This topic has already been solved. thank you for your continued input but you can see the the results leading to the final post here:

Viewing 15 posts - 16 through 30 (of 30 total)

You must be logged in to reply to this topic.