When you store all of your goodies (the photos, posts, and such) that you display on your web pages in a database, you gain the ability to create web pages dynamically — as they are served to the visitor of your site.
That means you can create a different page for visitors who prefer chocolate to those who prefer sour gumdrops.
And you can make it fast and easy to search across all of your content at once in many different ways.
Imagine you have a Web site where you sell 657 kinds of candy. How many web pages would you need to create?
Here’s how a static site stacks up against a dynamic site when you have more than 100 pages or products to produce:
- With a dynamic website (created with a CMS, such as WordPress, Joomla, Drupal or any of hundreds of other options), you create just one page template with the design for your candy products pages — and then you add special code that dynamically pulls product name, image, description, and any other pertinent information from a database and displays it in that one page template each time a visitor requests one of the 657 kinds of candy. That means you don’t actually have 657 pages, you have one template and a database full of content. That allows you to update, sort, mix and match your candy data — whenever and however you want — to create a virtually infinite number of pages that exist only as long as visitors to your site are viewing them.
- On a static website created with a program like Dreamweaver, you’d have to create 657 pages (or more), one for each candy product, plus a front page. If you ever wanted to change the way those pages look, you’d have to change all the pages.
- Using Dreamweaver templates on a static web site (covered in our Dreamweaver tutorials) will get you some of the same advantages you’d get from a dynamic site — such as global updates to common parts of a page — but you still have to go through and create the unique parts of every one of those 657 distinct pages, and then upload all of them to your Web server. (If your site is less than 50 or 100 pages, Dreamweaver templates may be fine, but once you get to a site with more than 500 pages, it’s definitely time to graduate to using a database to manage your content.
- When you compare the two types of site development options, dynamic Web sites clearly offer advantages to site owners who have a lot of data, such as items for sale, or articles with sections and subsections, that you want to present to the world in a consistent format.
- A dynamic site saves time because you don’t have to create individual pages for every product or for every different type of product listing. With a dynamic site, you invest more time up front, but if you’re working on a site that’s more than 100 pages or so, the dynamic approach is probably more efficient in the long run.
- Dynamic sites enable you to display the same product information in different combinations. So, for example, you could create one template that displayed only the name and photo of each kind of candy in a long list, and then another template that displayed all the product information for each type of candy, including a detailed description, pricing information, additional photos, and so on.
- (If you’ve ever shopped on Amazon.com or Godiva.com, you’re familiar with the concept.) You could also create one page that listed only chocolate candy and another that listed jelly beans. One big advantage is that if you change the name of a candy bar, you simply change the name once in the database, and it’s automatically changed on all the pages created from that entry in the database.
- Dynamic sites enable you to create links between pages with related information — automatically — so visitors can drill down to find the details they want. For example, you can set up one template that is designed to display the kinds of candy you sell, but specify that only ten items should appear on each page. Your dynamic site will then respond automatically — generating as many pages as needed to display all your products (at ten per page), and linking each page to the next. If you add more products to the database, the system generates more pages as needed, also automatically.
Considering the disadvantages of a blog or other dynamic Web site
Before you get too excited about all of the advantages of a dynamic Web site, keep in mind that there are a few disadvantages as well. Dynamic sites are harder to develop and require much more advanced skills to create and maintain. They can also be more expensive to host on a commercial service provider because they require more resources, and software, on your Web server.
(Learn more about the differences between creating a web site with Dreamweaver and a blog with wordpress.)
Comparing server-side versus client-side scripts
Two types of dynamic Web technology exist: Web pages created with server-side scripting and those created with client-side scripting.
Server-side scripting is installed and executed on a Web server. This chapter focuses on the kinds of dynamic sites you can create with server-side scripting — which enables a dynamic site to function with far more complexity — for example, pulling data from more than one data source to give potential customers on an e-commerce site custom-tailored recommendations based on the search terms they enter, as well as on the company’s current inventory.
Drawing information from a variety of sources makes it possible to deliver tailored messages that say things like: “You searched for jelly beans, and we think you might also like the jelly bean bouquets we have on sale this week.”