2

So it looks like most CMS uses templates, like WordPress or ghost or all other CMS uses templates. But we can still see some flat file CMS on the market. So what's the difference between them?

Is flat file CMS really serves content faster? Or is it simply because it's better to serve through CDN? Since you can think rendering template as combine data with a template. So unless you're data is saved as markdown, isn't it just as simple as joining strings (if we put loops in template aside)?

Or the loop is the main reason we use templates instead of flat file? Since the file size shouldn't matter at all on modern servers where you got up to 10GB of storage for the most basic plan.

Last will the connection and queries between databases really make difference on response speed?

So why should we use templates instead of flat file, or vice versa?

  • 1
    By "flat file", don't you mean "static"? As in a statically generated website. A "flat file" is generally the way data is stored (in a "flat file" as opposed to a relational DB, like MySQL). Consequently you could have a system that uses "templates" and "flat files". Bear in mind that the development of a site can be a separate process to the distribution/publishing. A site can be developed using templates and DBs (for ease of development) and distributed as a "static site". And then you also have caching... a template/DB site can be cached as static files (managed by the CMS). – MrWhite Aug 21 '18 at 22:31
  • @Andrew-at-TW, all three ones — database-driven CMSs like WordPress, flat-file CMSs and static site generators (SSG) — use templates. As MrWhite mentioned, the difference is the way of storing data and not related to the templates. Since flat-file platforms store data in files, they render pages faster. – stckvrw Oct 10 '18 at 19:07
2

I'd estimate that 90% of websites use a content management system with templates these days. The advantages of doing so have almost nothing to do with speed and everything to do with convenience.

  • A CMS system allows you to edit content from your web browser after logging into your site as a content contributor or administrator. Sites built with static files need to be uploaded through FTP.
  • You don't need to know HTML to edit in most CMS systems. They usually have a WYSIWYG content editor. For a static site you will either be editing HTML, or have to use a desktop HTML editor.
  • It is easy to modify your template with a CMS. WordPress allows you to completely change to any of thousands of different themes with a couple clicks. With a static site, every page has to be edited when you want to change your template.
  • Many CMSes offer thousands of plugins that easily extend the functionality of site. With a static site you are much more likely to have to implement addional functionality from scratch.

You mention CDNs, but they can be used effectively with either a CMS or with static files. I don't see how desiring a CDN would influence the choice of CMS vs static site.

CMS systems can be very slow. To run a CMS you need a good host. You need to install caching plugins. You need to ensure that your database is up to speed. You can make a CMS run very well, but I'd say that it is easier to tune a static site for performance.

That being said, the limiting factor for website performance is often the amount of the site that cached in memory. Web servers serve content much faster when it is already in memory than when it has to be scraped off disk or loaded from a database. Because the template of a static site is duplicated on every page, a CMS has the potential to run faster than a static site because more content can ultimately be cached.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.