Introduction to dynamic pages
February 14, 2005
One of the most powerful features of blogs and other content management systems (CMS) is that they can create pages “on-the-fly” that to all intents and appearances look like a hand-built static web page. This allows you to focus on developing your content itself, while the software generates the pages for you.
Introduction to Dynamic Pages
When using a content management system (CMS), or a weblog (which is a variety of content management system), pages are built dynamically.
A dynamic page is built by separating the content of the page (typically the “body copy” of the page, plus other key elements) from the page design itself.
The content is stored in an easy-to-retrieve fashion (typically by adding it to a database), and the page design is made into a template.
If you have ever used the “mail merge” facility of a word processor, the idea of a template will already be familiar to you. The elements that are common to all pages are placed in the template, along with areas that will be “substituted” or “replaced” by the content when the page is generated.
For example, our “common elements” to all pages may include the typography and layout of the page, the header and footer, and navigation elements. These will be the same on all of the pages that will be generated. Our content elements may include the body copy of the page, the title of the page, a header, and a summary of the page.
When our dynamic page is requested, a server-side script “assembles” our page, adds our content elements, and delivers a page to the viewer that is identical to a page that had been manually constructed — all of the “smarts” of the operation occur on the server.
The advantage of a system such as this is that you can design the “standard page” for a section of your site once, and then simply concentrate on developing your page content. Producing several hundred (or several thousand) pages in this manner means that you can save a substantial amount of time (or money, if you hire your web development done) by only having to handle the “web development” a single time.
A further advantage is that if you should want to change the look and feel of your pages in the future, or add or change features of your header, footer, or navigation, you can make the change a single time, in a single place, and all of your pages are updated instantly.
You can often see that dynamic pages are being produced by looking at the “URL” of the page (visible in the address bar of your web browser). For example, an url of the form “http://www.example.com/index.php?id=12” may be telling the server side script (index.php in this case) to display the article with the id “12”.
In many cases, this will be disguised. One reason for disguising this is that search engines traditionally index dynamically generated sites much more slowly (to avoid overloading scripts that might be very slow). Other reasons for disguising dynamic URLs include not exposing the underlying technology to potential hackers, and not “locking in” a particular technology.
In our example above, the “disguised” URL may look more like “http://www.example.com/articles/12/” — this does not indicate to search engines that the page is dynamic, does not show what the underlying technology (if any) might be, and leaves the site owner free to replace the underlying files (perhaps the site will change server side scripting technology, and index.php?id=12 might become articles.asp?show=12) without potentially breaking links or losing search engine traffic on the URL.
In some cases, the CMS may actually generate static pages — rather than producing the pages “on demand”, it will “batch” create all of the pages and store them as simple HTML files that are served to the visitors.
This has the advantage of potentially operating faster when a heavy traffic load is in place (the “on demand” script causes a slight delay when generating the content, which is usually not noticeable under normal loads), but adds a significant load on the server during batch generation (possibly generating complaints from the web host), and increases the amount of storage space needed to store the site (the “on demand” approach takes very little space.)
The other advantage of this approach is that it does not require “disguising” the URLs, which may be difficult on some web servers.
Disguising URLs is typically done with a tool called “mod_rewrite” on Apache servers (usually running under Unix or Linux). While it can be done on Windows servers running Microsoft’s IIS web server, it requires a separately purchased software package and help from the web host.
While all of this may look complex, once the software (a server-side script) is installed on your website, creating new pages with it just happens “automatically”.
For example, if you install a blogging software package, you’ll have a password-protected administrator page, where you can go enter the text of a new article or blog post. When you press the “publish” button, your content is stored in the database, and your new page just “appears”. It may also be added to an index of entries on a specific topic, an index of new entries, or various other sections of your site. If you offer syndication for your visitors, it will also be added to your syndication feed, and available for viewing by readers using news readers or services such as bloglines. All without you having to do anything more than type in your text.
Leveraging features such as this can substantially reduce the amount of time or cost spent on site development, and make it much easier for you to focus on adding fresh content to your web site.