什么是静态站点生成器?

时间:2023-01-15 10:36:56

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.

放弃Wordpress后,我一直在试验Jekyll创建一个博客。我选择它(通过Ghost)来帮助我在博客时学习Web开发的基础知识。此外,GitHub页面上的免费托管是整洁和免费的。

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

什么是静态站点生成器(如Jekyll),为什么它们存在?

2 个解决方案

#1


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

在Treehouse中使用Jekyll和GitHub Pages课程构建博客:

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.

静态站点生成器获取一组模板和原始文本文件,通过转换器和渲染器运行它,然后生成一个准备在任何Web服务器上发布的纯HTML网站。

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).
  • 减少维护工作。没有数据库意味着不需要配置和维护数据库或内容管理系统(CMS)。

  • Free hosting on GitHub Pages
  • 免费托管GitHub页面

  • Use your own domain name
  • 使用您自己的域名

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

课程链接:https://teamtreehouse.com/library/build-a-blog-with-jekyll-and-github-pages

#2


A static site has 3 components:

静态站点有3个组件:

  1. HTML files (or other content to serve via the web, like .txt files)
  2. HTML文件(或通过网络提供的其他内容,如.txt文件)

  3. referenced assets (js, images, css)
  4. 引用资产(js,图像,css)

  5. a web server
  6. 一个Web服务器

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.

与wordpress相比,没有数据库可以从中检索数据,其中所有帖子和页面都存在于数据库中。没有用于处理信息和呈现内容的服务器端脚本引擎。

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.

存在静态站点生成器,为您提供模板,共享数据和自定义标记等工具,以帮助您创建Web服务器将要提供的静态HTML页面。

The benefits of a static site are:

静态站点的好处是:

  • Security. The web server is the only moving part.
  • 安全。 Web服务器是唯一的移动部件。

  • Portability. The HTML files will render the same when served from your local machine as they will on the web.
  • 可移植性。从本地计算机提供的HTML文件将与在Web上提供的文件相同。

  • Speed. When almost everything is cacheable, compressed, and doesn't require any data crunching, things load very fast.
  • 速度。当几乎所有东西都是可缓存的,压缩的,并且不需要任何数据处理时,事情加载速度非常快。

#1


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

在Treehouse中使用Jekyll和GitHub Pages课程构建博客:

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.

静态站点生成器获取一组模板和原始文本文件,通过转换器和渲染器运行它,然后生成一个准备在任何Web服务器上发布的纯HTML网站。

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).
  • 减少维护工作。没有数据库意味着不需要配置和维护数据库或内容管理系统(CMS)。

  • Free hosting on GitHub Pages
  • 免费托管GitHub页面

  • Use your own domain name
  • 使用您自己的域名

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

课程链接:https://teamtreehouse.com/library/build-a-blog-with-jekyll-and-github-pages

#2


A static site has 3 components:

静态站点有3个组件:

  1. HTML files (or other content to serve via the web, like .txt files)
  2. HTML文件(或通过网络提供的其他内容,如.txt文件)

  3. referenced assets (js, images, css)
  4. 引用资产(js,图像,css)

  5. a web server
  6. 一个Web服务器

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.

与wordpress相比,没有数据库可以从中检索数据,其中所有帖子和页面都存在于数据库中。没有用于处理信息和呈现内容的服务器端脚本引擎。

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.

存在静态站点生成器,为您提供模板,共享数据和自定义标记等工具,以帮助您创建Web服务器将要提供的静态HTML页面。

The benefits of a static site are:

静态站点的好处是:

  • Security. The web server is the only moving part.
  • 安全。 Web服务器是唯一的移动部件。

  • Portability. The HTML files will render the same when served from your local machine as they will on the web.
  • 可移植性。从本地计算机提供的HTML文件将与在Web上提供的文件相同。

  • Speed. When almost everything is cacheable, compressed, and doesn't require any data crunching, things load very fast.
  • 速度。当几乎所有东西都是可缓存的,压缩的,并且不需要任何数据处理时,事情加载速度非常快。