Header & Footer Separate Files

Discussion in 'HTML & Website Design' started by Fix Johnson, Oct 7, 2014.

  1. #1
    My site is designed with Get Header and Get Footer function added to index page. I was using the WC3 Markup service, with Tidy for clean up, and it automatically puts header and footer information together.

    Is there any negative SEO to having Header.php and Footer.php load separately.

    If there is would it be better to put both together for index page and just let rest of pages continue to load header and footer separately?

    Thanks for any advice for this :)
     
    Fix Johnson, Oct 7, 2014 IP
  2. 1SEOcom

    1SEOcom Greenhorn

    Messages:
    56
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #2
    No negative to SEO when you are using includes in PHP. If you are scared of your page speed, just run it through GTMetrix and Google Page Speed Tester to see what your load times are like. Includes generally do not slow your website down.
     
    1SEOcom, Oct 9, 2014 IP
  3. ftws

    ftws Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #3
    Hi, actually the php-includes is what happens in the background, what matters for SEO is only the rendered HTML that is accessible. Of course, - as already said - page speed is another factor, but not much related to how much includes are used.
     
    ftws, Oct 10, 2014 IP
  4. adirohan

    adirohan Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    I would say Dynamic pages are always the best .

    There is no downside to SEO and you can change the header and footer for all your pages by editing just two files.
     
    adirohan, Oct 12, 2014 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Been programming for over three decades, doing websites for almost half that, HAVE no clue what "Get Header" and "Get Footer" means -- do you mean PHP includes? (as your later sentence would imply)

    Do you mean the markup validation service? Not familiar with there being such a thing as "Markup Service"

    If you have to use something like TIDY, you're not typing your code in properly or are using a garbage editor. TIDY is for cleaning up other people's messes, not your own.

    Also not sure what you mean by "load separately" -- but if you mean including them at the start and end, it outputs the same HTML as if it were a monolithic file, so why would it have any impact one way or the other? Do a view source of the page put together after PHP runs -- does it look any different from a monolithich HTML file? Of course not. That's what the search engine sees, it could give a flying purple fish what you are doing server side, all it sees is the final HTML output.

    If you do mean includes, some advice -- NEVER allow includes to output anything should the visitor try to call them directly, it's sloppy practice that results in possible security holes. Put the stuff in your includes into a function, then call that function. It can also be more efficient as it means you can put both the header and footer in one file (so one less filesystem search and load) and pass variables to the functions instead of polluting the global namespace.

    common.template.php
    <?php
    
    function template_header($pageTitle = false, $desc = false, $keywords = false) {
    	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html
    	xmlns="http://www.w3.org/1999/xhtml"
    	lang="en"
    	xml:lang="en"
    ><head>
    
    <meta
    	http-equiv="Content-Type"
    	content="text/html; charset=utf-8"
    />
    
    <meta
    	http-equiv="Content-Language"
    	content="en"
    />';
    
    if ($desc) echo '
    <meta
    	name="description"
    	content="', $desc, '"
    />';
    
    if ($keywords) echo '
    <meta
    	name="keywords"
    	content="', $keywords, '"
    />';
    
    <meta
    	name="viewport"
    	content="width=device-width; height=device-height; initial-scale=1.0"
    />
    
    <link
    	type="text/css"
    	rel="stylesheet"
    	href="screen.css"
    	media="screen,projection,tv"
    />
    
    <link
    	rel="shortcut icon"
    	href="favicon.ico"
    />
    
    <title>
    	', isset($pageTitle) ? $pageTitle . ' - ' : '', 'Site Title'
    </title>
    
    </head><body>
    
    <div id="top">
    
    	<h1>
    		<a href="/">
    			Site Title
    			<span><!-- image replacement sandbag --></span>
    		</a>
    	</h1>';
    
    }
    
    function template_footer() {
    	echo '
    	
    <!-- #top --></div>
    
    </body></html>';
    }
    
    ?>
    Code (markup):
    With a sample page being thus:

    sample.php
    <?php
    	include('common.template.php');
    	template_header(
    		'Sample Page',
    		'Describe the page and site here',
    		'Seven,or,eight,words,that,exist,inside,body'
    	);
    ?>
    
    	<h2>Sample Page</h2>
    	<p>
    		Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non laoreet eros. Maecenas volutpat quam porta felis ullamcorper, at auctor purus dignissim. Nullam facilisis dolor justo, vitae euismod tellus vestibulum vel. Praesent in risus vel mi euismod molestie. Mauris at magna sem. Maecenas neque ex, tempor quis semper quis, mattis quis lacus. Praesent lacus neque, tempor id mattis suscipit, mattis sed velit. Ut elementum nibh turpis, sit amet sodales sem eleifend auctor. Suspendisse facilisis pellentesque ligula, non tempus turpis varius et. Duis felis magna, porttitor at massa eget, vestibulum lobortis velit. Suspendisse metus ante, blandit eu sollicitudin ac, luctus quis felis. Cras fermentum auctor egestas. Fusce dignissim fringilla convallis.	
    	</p>
    	
    <?php template_footer(); ?>
    Code (markup):
    One include, no vars in the global space, and you can still pass the values that might be different from page to page like the description, keywords and page title.

    ... and search engines wouldn't know the difference between that or a static file. ALL they see is the HTML output, not what the server is doing on the back-end.
     
    deathshadow, Oct 13, 2014 IP
  6. adirohan

    adirohan Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #6
    Very well explained !
     
    adirohan, Oct 25, 2014 IP