What is a static site generator?

南笙酒味 提交于 2020-05-11 05:24:13

问题


After ditching Wordpress, I've been experimenting with Jekyll to create a blog. I chose it (over Ghost) to help learn the basics of web development while I blogged. Also, the free hosting on GitHub Pages is neat and free.

What exactly is a static site generator (like Jekyll), and why do they exist?


回答1:


From Build a Blog with Jekyll and GitHub Pages course on Treehouse:

A static-site generator takes a set of templates and raw text files, runs it through a converter and renderer, then generates a plain HTML website that's ready to publish on any web server.

Advantages:

  • Sites load fast since we're serving regular pages to the browser and don't need to talk to a database on each request.
  • Sites are more secure because there's no database or dynamic content that can be hacked.
  • Less maintenance involved. No database means no need to configure and maintain a database or content management system (CMS).
  • Free hosting on GitHub Pages
  • Use your own domain name

Course Link: https://teamtreehouse.com/library/build-a-blog-with-jekyll-and-github-pages




回答2:


A static site has 3 components:

  1. HTML files (or other content to serve via the web, like .txt files)
  2. referenced assets (js, images, css)
  3. a web server

There is no database from which data is retrieved, compared to something like wordpress where all of your posts and pages live in a database. There is no server-side scripting engine with which to process information and render content.

Static site generators exist to provide you with tools like templating, shared data, and custom tags to assist in the creation of the static HTML pages that your web server will be serving.

The benefits of a static site are:

  • Security. The web server is the only moving part.
  • Portability. The HTML files will render the same when served from your local machine as they will on the web.
  • Speed. When almost everything is cacheable, compressed, and doesn't require any data crunching, things load very fast.


来源:https://stackoverflow.com/questions/30181349/what-is-a-static-site-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!