I will create a webpage that has a sidebar, and the sidebar will have links to other pages and stuff. The way I am coding, for each link on the sidebar, I have another HTML document. The sidebar links just link to another .html file, which contains the website template/layout whatever you want to call it. So I have an index.html that is the home page, then an about.html, etc. And for each of the html documents, the file contains the code for the layout of the entire website (the sidebar, footer, etc). So between the different links that the sidebar links to, the only difference is the content. So if I want to change the layout of my webpage (the color of the sidebar, for example) I will have to go to each HTML document and change it.
So my question is how are people supposed to go about doing this? I don’t think I am doing it correctly. Are you just supposed to have one file that contains the template?
Moneydev,
What you are looking for is a templating system. If you want to stick with pure HTML you’ll have to use external tools to help you because it doesn’t have a built-in way to template. Dreamweaver has the capacity to allow you to define areas inside your webpages to indicate they are the same area, to be maintained “as one” throughout your entire website.
The way that works though, is actually pretty low-tech. What it does is search through ALL the files in your Dreamweaver managed website and “search and replace” the section when you edit it from the “master location” which is determined when you set it up in the first place.
Ali Hamze suggests using ‘includes’ inside PHP projects. That is the common approach for PHP, but I’m biased and much prefer ASP.NET’s answer to templating. It is a combination of “.master” (pages) and “.ascx” (controls) that allow you to template and re-use these in nested fashion. It is FAR beyond a simple “search and replace” (as done by Dreamweaver with your HTML) but would require you learn a new development environment.
So what it boils down to, is you can stick with HTML which will be far simpler and allow you to focus on learning HTML/CSS and JavaScript. This is great to build a foundation for development… however, to really move into the “big leagues” I’d recommend choosing an IDE.
As a long time Windows guy, I do favor ASP.NET via Microsoft Visual Studio and Microsoft SQL for the databases. That said, I’m the kind of person that can drink Coca-Cola, and still like Pepsi. If you’d like to look into PHP or Java, those are great options too. Here are places I’d go if I wanted a FREE and powerful IDE to get my web development life off to a healthy start:
ASP.NET (Microsoft Visual Studio) — Read about ‘Master pages’ and ‘Control files’ for templating
http://www.microsoft.com/express
(I prefer Microsoft SQL (Express Edition is fine) for databases, though you CAN use mySQL if you like)
PHP (Eclipse IDE for PHP) — Look into ‘includes’ for templating
http://www.eclipse.org/projects/project.php?id=tools.pdt
Java (Eclipse IDE for Java) — Look into ‘http://www.stringtemplate.org/’ for templating
http://www.eclipse.org/downloads/packages/eclipse-ide-javascript-web-developers/indigosr2
(for the above, if you want a database behind the scenes, check out mySQL)
http://www.mysql.com/
FYI: You might find Microsoft’s IDE the least intimidating, though PHP isn’t too tough to start with. Java may be challenging if you’re new.
Happy coding!