How Do You Call Header.html/footer.html In A Web Page?
Solution 1:
by using include():
<!DOCTYPE htmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=utf-8" /><title>Your page</title><styletype="text/css"><!--Your styles ect that make your page--></style></head><body><divclass="container"><divclass="header"><?phpinclude('./site_content/header.html');?></div><divclass="sidebar"><?phpinclude('./site_content/sidebar.html');?></div><divclass="content">
your content
</div><divclass="footer"><?phpinclude('./site_content/footer.html');?></div></div></body></html>
Solution 2:
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 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.
Post a Comment for "How Do You Call Header.html/footer.html In A Web Page?"