In the early days of the internet there was only one way to make a website: using several HTML files. Today, however, we can choose the best way to create a site, balancing pros and cons to provide a better experience for maintainers and users.
This article is for those who still have doubts about what a static or dynamic website is. If you have no doubts about it at all, feel free to read other articles of the blog!
Dynamic sites
Dynamic sites: pages generated at execution time
Pros
It is no longer necessary to create hundreds of HTML files: they are generated the moment they are accessed on the server. News portals, complex systems can be created, thanks to this possibility.
The well-known Wordpress is the result of this type of website creation. It provides tools for the creation of content in a more accessible way for a user that is lacking on programming. There are several other systems like that.
Cons
The cost comes with hosting, because dynamic sites require more server processing, and if the server is not fast enough, there will be instabilities. In addition, the concern about security increases, because if it is not properly implemented, sensitive information can be accessed from the database.
Static sites
Static sites: pages are shown like they were built.
Static websites are just the old school HTML files, from the beginning of the internet. Add images and scripts to them and that's it. It is the native way of displaying content in the browser.
Pros
They are fast and require little from the server, as there is no processing behind them, just the display of a ready file. Hence the name "static": it is presented as is.
Cons
The problem is that maintenance becomes complex: each change in a link, for example, must be changed manually in all HTML files on the site. On a large website this is not viable, for obvious reasons.
Static site generators
Static generated sites: pages created with other technologies are compiled to static content.
Fortunately, to overcome this difficulty there are the so-called static website generators, which provide a blend between the ease of development of a dynamic website, without a database. And the distribution of the result is a pure static website. This blog makes use of a static website generator called Gatsby.
What type of website to choose?
If the site consists only of pages where the content does not change every day (or time), it is better using a static one, either the standard one or with a generator. There is no need to host a dynamic website for most simple institutional websites. This makes hosting cheaper and requires less maintenance costs.
However, if the website has information changing all the time, or it is a system that reacts to each case presented to it, it is necessary to use a dynamic website to guarantee it works. Static pages do not interact with information, only present it.
Mixed system
It is best, if possible, to use a mixed system: information pages served in a static way and more complex pages such as stores and systems with authentication and everything else, in a dynamic way.