webdonkey — 2011-01-31T18:12:34-05:00 — #1
I've been working so much with cms like wordpress lately that it's been ages since I built a HTML/CSS site from scratch.
My mindset is creating sites based on themes and templates. What is best practice these days to repeat sections of sites across pages without repeating code? Should I use php includes? Any clever way to do this now?
webcosmo — 2011-01-31T18:46:27-05:00 — #2
most modern web technology works with code reuse.
include is one of the choice with php.
with asp .net you can build master page template and reuse it for different pages.
stevie_d — 2011-02-01T07:22:46-05:00 — #3
The easiest way is to use server-side includes. Wherever you want to pull in a repeated code block, just add the line
<!--#include virtual="../block1.htm" -->
and then save the appropriate fragment file as "block1.htm". You can include as many different blocks as you want in any one page, but they do all have to be on the same domain.
You will need to either save your main files with a .shtml extension, or configure the server to treat all files as though they are .shtml.