DEV Community

Cover image for Static vs dynamic websites: which to use?
Wahaab Siddique
Wahaab Siddique

Posted on

Static vs dynamic websites: which to use?

What is a static website?
A static website consists of a series of HTML files, each one representing a physical page of a website. So on static sites, each page is a separate HTML file. When you visit the homepage, you are viewing the actual homepage file.

Even if two pages contain a chunk of identical content (like a footer), they both contain two versions. So, if you want to update the footer, you must do so twice, once on each page. Publii is an example of Static Site Generator.

Alt Text
What is a dynamic website?
A dynamic website uses server technologies (such as PHP) to dynamically build a webpage right when a user visits the page.

Basically, what happens is the user goes to a certain web address and the server finds a bunch of different pieces of information that it writes into a single cohesive web page, which is what you see. Wordpress is an example of Dynamic website CMS.

Alt Text

Benefits of a static website
Due to their relative simplicity, a static website doesn’t require as much development know-how as a dynamic website might to build from scratch. With just a notepad document, anyone can create a file in HTML and CSS which contains their content. This works well for those who have only basic development experience, and simply want to create a website consisting of a few pages that display information.

Benefits of a dynamic website
While a static site provides faster loading times, dynamic websites make up for it in functionality and ease of use. Where static sites are most effective when the data doesn’t change often, dynamic sites can alter their data as the user navigates the website.

People usually run their blog using a CMS like WordPress
When most people create a blog they immediately choose a WordPress blog -- or something similar which is also a content management system (CMS).

People usually choose a CMS because it is 'easy to change and update'. They are also not aware of the alternative.

A CMS is a dynamic website
A dynamic website is constantly running code to render the website - or in this case blog. Running code for every request has several drawbacks:

Hackers can potentially inject malware into the site and have it execute.
Pageloads are slow(er).
The Website can become unreliable due to incompatible plugins, malfunctioning database, etc... Essentially, multiple parts need to work together.
Hosting costs are high(er).
It may be a better idea to run a blog using a static website
The rule-of-thumb is the following: If all visitors to your website need to see the same pages with the same content, then you should choose a static website. If, on the other hand, various visitors to your site need to see different content on different pages, then you should opt for a dynamic website.

In the case of a blog, all visitors need to see the same content and the same pages.

Static Websites address the drawbacks of dynamic websites:

Malware cannot be executed on a static website, simply because no code is running.
Static sites load super fast. The HTML is already generated, so it can be served to the visitor straight away. No need to render anything.
Fewer parts, which means that less can go wrong. No incompatible plugins or corrupt databases.
Free hosting is possible on sites like Github or Netlify.
Static website can easily be created using a Static Site Generator
There is no need to be a coder to build a static website. For several years, so-called Static Site Generators (SSG) have existed. All you need to do is to create blog posts and pages in Markdown and then run the SSG to create the website.

When you want to update your static website, then you simply update your posts and pages using Markdown and then re-run the SSG.

The best-known SSG is Jekyll, but there are plenty of others. What does characterize most SSGs is that they are command-line based. For tech-oriented users, this is not an issue but for non-tech users, this is a major turn-off.

Recently there has been a new development, though...

A good and easy to use Static Site Generator is Publii
Publii is an SSG which has an easy to use GUI backend. This backend runs on your Desktop. No command-line knowledge is needed.

The ease of use makes it attractive for tech-users as well as non-tech users. Hence this a viable alternative to Wordpress and other CMSes.

Top comments (0)