0

I've been making a website with about 25 pages and every time I want to update the nav bar, or the footer, I have to go through every page and make the change!

Surely there is a way to have the header and the footer (and the side bar!) in separate documents and call them in the same way a CSS is called so they don't have to be repeated on every page.

Bonus: Is this likely to affect SEO in any way? Might it slow down the site?

Thank you,

Tara

7
  • 1
    -1 for asking a question that can be answered in 10 minutes on google; (I'm in a harsh mood tonight, sorry). Commented Jul 15, 2011 at 10:29
  • 1
    @vascowhite Actually, I've spent all morning looking on Google and I can't find an answer! Lots of people are saying very different things. Commented Jul 15, 2011 at 10:33
  • because there are so many different technics, you have to choose one and read more about it to learn :) Commented Jul 15, 2011 at 10:36
  • @vascowhite do you mean msdn.microsoft.com/en-us/library/aa140051(v=office.10).aspx ? :)) Commented Jul 15, 2011 at 10:43
  • @Tara Honestly, this is a question I answered for myself years ago purely through online tutorials that I found through Google. I can't believe they've all jus disapeared! Just putting your title into google brings up several useful resources. Ignore the first one it's your question :) Commented Jul 15, 2011 at 10:44

2 Answers 2

4

by using include():

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Your page</title> <style type="text/css"> <!--Your styles ect that make your page--> </style></head> <body> <div class="container"> <div class="header"><?php include('./site_content/header.html');?></div> <div class="sidebar"><?php include('./site_content/sidebar.html');?></div> <div class="content"> your content </div> <div class="footer"><?php include('./site_content/footer.html');?></div> </div> </body> </html> 
Sign up to request clarification or add additional context in comments.

2 Comments

np, experiment with php variables and you can turn your 25 static html pages into 1 page that calls other pages/content based on what links are clicked ect...
That sounds a bit like AJAX? From an SEO standpoint, I think that separate 'niche' pages will probably work better. But it's a cool idea in any case. Thanks again :)
1

HTML itself - ignoring framesets and iframes which do have an effect on SEO and are generally not really recommended - does not have any method to include partial HTML.

You can however use PHP (or SSI if you're oldskool) for such. It has a command to include partial files, it's called include PHP Manual.

PHP needs to be activated on your server for it. To keep this transparent you might want to map the .html file extension to PHP or use Mod_Rewrite to do that. That depends on the type of server and it's configuration.

Might it slow down the site?

The server has more work to do to process the request, therefore it slows down the site a little bit. But normally for a simple site you won't notice that much.

To prevent such, it's possible to build a simple caching mechanism on top that will convert the dynamic PHP output into static files on the fly.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.