编辑器生成静态网页_使用静态网站生成器的7个理由

news/2024/5/20 2:32:14/文章来源:https://blog.csdn.net/culi3118/article/details/108382465

编辑器生成静态网页

Static site generators have become increasingly popular and, if my prediction is correct, usage will explode during 2016. Let’s establish what we mean by the term “static site generator”

静态站点生成器已变得越来越流行,如果我的预测正确的话 ,其使用量将在2016年激增。让我们建立“静态站点生成器”这个术语的含义……

static site generators

什么是静态站点? (What is a Static Site?)

Think back to the first website you built. Most developers start by creating a series of pages contained within individual HTML files. Each will call in assets such as images, CSS and perhaps a sprinkling of JavaScript. You possibly launched these files directly from the file system without a web server. Life was simple.

回想一下您建立的第一个网站。 大多数开发人员从创建单个HTML文件中包含的一系列页面开始。 每个人都会调用资产,例如图像,CSS以及一些JavaScript。 您可能直接从文件系统启动了这些文件,而没有Web服务器。 生活很简单。

Difficulties arise as your site becomes larger and more complex. Consider navigation: it may be similar in every file, but adding a new page requires updates to every other. Even references to CSS and images can become awkward as folder structures evolve. You may have considered options such as server-side includes or PHP, but an easier option can be a content management system (CMS) …

当您的站点变得越来越大和越来越复杂时,就会出现困难。 考虑导航:每个文件中的导航可能都相似,但是添加新页面需要彼此更新。 随着文件夹结构的发展,甚至对CSS和图像的引用也可能变得笨拙。 您可能已经考虑过诸如服务器端包含或PHP之类的选项,但是更简单的选项可以是内容管理系统(CMS)…

什么是内容管理系统? (What is a Content Management System?)

A CMS typically provides administrative control panels — which allow authors to write content that’s stored in a back-end database. When a visitor requests a URL, the CMS:

CMS通常提供管理控制面板-允许作者编写存储在后端数据库中的内容。 访客请求URL时,CMS:

  1. determines which page is required

    确定所需的页面
  2. requests appropriate content from the database

    从数据库中请求适当的内容
  3. loads an HTML template (normally from the file system)

    加载HTML模板(通常从文件系统加载)
  4. renders the content within the template, and

    在模板中呈现内容,并且
  5. returns a formatted HTML page to the visitor’s browser.

    将格式化HTML页面返回到访问者的浏览器。

This occurs almost instantly. The template can include code to generate menus according to the navigation hierarchy. Life is sweet, and more than one in four people choose the PHP/MySQL-powered open source WordPress CMS to manage their website.

这几乎立即发生。 模板可以包括用于根据导航层次生成菜单的代码。 生活是美好的,四分之一以上的人选择使用PHP / MySQL支持的开源WordPress CMS来管理他们的网站。

Unfortunately, a CMS raises a different set of issues:

不幸的是,CMS提出了一系列不同的问题:

  • You need to adhere to the CMS’s way of working. It can be awkward to add custom text or components.

    您需要遵守CMS的工作方式。 添加自定义文本或组件可能很麻烦。
  • The server is doing more work, and performance can be affected.

    服务器正在做更多的工作,并且性能可能会受到影响。
  • There are additional points of failure. A software upgrade or database failure can bring your site down.

    还有其他一些故障点。 软件升级或数据库故障可能会使您的网站瘫痪。

什么是静态网站生成器? (What is a Static Site Generator?)

An SSG is a compromise between using a hand-coded static site and a full CMS, while retaining the benefits of both. In essence, you generate a static HTML-only website using CMS-like concepts such as templates. The content can be extracted from a database but, more typically, Markdown files are used.

SSG是在使用手动编码的静态站点和完整的CMS之间的折衷,同时保留了两者的优点。 本质上,您使用类似于CMS的概念(例如模板)生成仅静态HTML的网站。 可以从数据库中提取内容,但是更典型地,使用Markdown文件。

The site generation can occur on your development machine or staging server. The resulting HTML files are then deployed to a live web server. Users will never know the difference.

网站生成可以发生在您的开发计算机或登台服务器上。 然后将生成HTML文件部署到实时Web服务器。 用户永远不会知道区别。

A related concept is a “Headless” or “Decoupled” CMS. These use an interface such as WordPress to handle content administration but allow other systems to access the data via a REST API. Therefore, an SSG could build a static website using WordPress page content extracted from an internal server. The resulting HTML files can be uploaded to a web server — but the WordPress installation need never be accessible from outside the organization.

一个相关的概念是“无头”“解耦” CMS。 它们使用诸如WordPress之类的界面来处理内容管理,但允许其他系统通过REST API访问数据。 因此,SSG可以使用从内部服务器提取的WordPress页面内容来构建静态网站。 可以将生成HTML文件上载到Web服务器-但从未需要从组织外部访问WordPress安装。

Popular static site generators include Jekyll, Pelican, Hugo and Metalsmith — see StaticGen for many more. Let’s examine the benefits of using one …

流行的静态站点生成器包括Jekyll , Pelican , Hugo和Metalsmith-有关更多信息,请参见StaticGen 。 让我们研究一下使用…的好处。

1.灵活性 (1. Flexibility)

CMSs normally constrain your options, because they’re tied to a database with specific fields. If you want to add a Twitter widget to some pages, you’ll normally require a plugin, a shortcode or some custom functionality.

CMS通常会限制您的选择,因为它们绑定到具有特定字段的数据库。 如果要在某些页面上添加Twitter小部件,通常需要使用插件,简码​​或某些自定义功能。

In a static site, the widget can simply be inserted into a file directly or using a partial/snippet. There are few limits, because you’re unshackled by the those imposed by a CMS.

在静态站点中,可以将窗口小部件直接直接插入文件中,也可以使用部分/片段插入。 没有什么限制,因为您不受CMS施加的限制的束缚。

2.更好的表现 (2. Better Performance)

Most CMS applications offer built-in or plugin-powered cache systems to ensure pages are generated and reused when possible. This is effective, although the overhead of managing, validating and re-generating cached pages remains.

大多数CMS应用程序都提供内置的或由插件驱动的缓存系统,以确保在可能的情况下生成和重用页面。 尽管保留了管理,验证和重新生成缓存页面的开销,但这是有效的。

Static sites are pre-cached pages which never expire. Files can also be minified prior to deployment to guarantee the smallest load. A static site will always perform better than a CMS-powered version using a similar template.

静态站点是永不过期的预缓存页面。 还可以在部署之前将文件缩小,以确保最小的负载。 静态网站始终会比使用类似模板的CMS支持版本更好。

3.较少的服务器端依赖性 (3. Fewer Server-side Dependencies)

A typical WordPress installation requires:

典型的WordPress安装要求:

  • a suitable operating system such as Ubuntu or CentOS

    合适的操作系统,例如Ubuntu或CentOS
  • a web server such as Apache or NGINX

    Web服务器,例如Apache或NGINX
  • PHP with associated extensions and web server configurations

    PHP及其相关的扩展和Web服务器配置
  • MySQL

    MySQL
  • the WordPress application

    WordPress应用程序
  • any necessary plugins

    任何必要的插件
  • the theme/template code.

    主题/模板代码。

These dependencies must be installed and managed. WordPress requires less effort than some other applications, but it’s still possible for a single update to any part to cause chaos.

必须安装和管理这些依赖项。 WordPress比其他一些应用程序需要更少的工作,但是任何部分的单个更新仍然可能引起混乱。

A static site is lightweight, and can be hosted by any web server able to return HTML files. There is nothing else to install, manage or update.

静态站点是轻量级的,并且可以由任何能够返回HTML文件的Web服务器托管。 无需安装,管理或更新。

4.提高可靠性 (4. Improved Reliability)

A CMS is complex, with many moving parts and points of failure. Run a WordPress site for any length of time and you’ll almost certainly encounter the dreaded “Failed to establish a database connection” error. Unforeseen CMS problems can arise from sudden traffic surges, which crash the database or restrict active connections.

CMS很复杂,有许多活动部件和故障点。 任意时间运行WordPress网站,几乎可以肯定会遇到可怕的“无法建立数据库连接”错误。 突发的流量激增可能导致无法预料的CMS问题,这可能使数据库崩溃或限制活动连接。

Serving a static site is less intensive — the server just has to return flat files. It’s still possible to crash a web server, but it’ll take considerably more concurrent requests.

为静态站点提供服务的强度较低-服务器只需返回平面文件。 仍然有可能使Web服务器崩溃,但是它将需要更多的并发请求。

5.优越的安全性 (5. Superior Security)

There are several reasons why someone may want to attack your website. Traffic hijacking, rogue advertising, linking, authenticity spoofing and malware hosting all permit an unauthorized user to make monetary and/or kudos gains.

有人可能想要攻击您的网站有几个原因。 流量劫持,流氓广告,链接,真实性欺骗和恶意软件托管都允许未经授权的用户获取金钱和/或荣誉。

A CMS opens a number of attack vectors. The most obvious is the login screen: it’s only as secure as the weakest user password. Be aware that any page running server-side code also offers potential exploits — for example, firing spam emails via your contact form. It may not be obvious that someone has gained access; the worst culprits want to stay hidden.

CMS打开了许多攻击媒介。 最明显的是登录屏幕:它仅与最弱的用户密码一样安全。 请注意,任何运行服务器端代码的页面也都具有潜在的漏洞利用-例如,通过您的联系表发送垃圾邮件。 有人获得访问权限可能并不明显; 罪魁祸首想躲藏起来。

A static site has little or no server-side functionality. You cannot access it via scripting or database security holes. Someone could still gain access via SSH or FTP, but they would struggle to do much damage other than defacing pages or uploading files. A quick git status or folder check can reveal break-ins. It’s then simple to change passwords, wipe the whole site and regenerate it again.

静态站点几乎没有服务器端功能。 您无法通过脚本编制或数据库安全漏洞访问它。 某些人仍然可以通过SSH或FTP获得访问权限,但是除了使页面涂污或上传文件外,他们还会造成很大的损失。 快速的git status或文件夹检查可以显示入侵。 更改密码,擦除整个站点并重新生成它很简单。

6.客户控制注意事项 (6. Client Control Considerations)

You spend weeks building attractive CMS themes for the client to trash their site within minutes of your hand-over. Using a CMS is not necessarily easy, and it offers considerable power to content editors. You can lock down rights such as plugin installation, but it won’t prevent someone changing fonts, adding weird colors, using poor photography or corrupting the layout.

您花了数周的时间来建立吸引人的CMS主题,以使客户在移交后的几分钟内就将其网站丢弃。 使用CMS不一定很容易,它为内容编辑器提供了强大的功能。 您可以锁定诸如插件安装之类的权限,但它不会阻止某人更改字体,添加怪异颜色,使用较差的摄影效果或破坏布局。

A static site can use Markdown files. That limits the user’s options; they make fewer mistakes and cannot adversely affect the pages. Some will miss the CMS content administration panels, but you can either:

静态站点可以使用Markdown文件。 那限制了用户的选择; 他们犯的错误更少,并且不会对页面造成不利影响。 有些人会错过CMS内容管理面板,但是您可以:

  1. use their existing CMS and cleanse data before generation, or

    在生成之前使用其现有的CMS并清除数据,或者
  2. provide simpler workflows such as editing Dropbox files in StackEdit.

    提供更简单的工作流程,例如在StackEdit中编辑Dropbox文件。

7.版本控制和测试 (7. Version Control and Testing)

Database data is volatile. A CMS permits users to add, delete or change content on a whim. Wiping the whole site is a few clicks away. You can back up databases but, even if that’s done regularly, you’re still likely to lose some data.

数据库数据易失。 CMS允许用户随心所欲地添加,删除或更改内容。 只需单击几下即可擦除整个网站。 您可以备份数据库,但是即使定期进行备份,您仍然可能丢失一些数据。

A static site is safe presuming your content is defined in Markdown files and you use a version control system such as Git. Old files are retained, and changes can be undone quickly. Testing becomes easier because the site can be generated and previewed anywhere — even on a client’s PC.

假设您的内容是在Markdown文件中定义的,并且使用了版本控制系统(例如Git),则静态站点是安全的。 保留了旧文件,并且可以快速撤消更改。 测试变得更加容易,因为可以在任何地方(甚至在客户的PC上)生成和预览站点。

With a little more effort, you can implement deployment systems to build the site on a staging server, then update the live server when new content has been reviewed and approved.

稍加努力,您就可以实施部署系统,以在登台服务器上构建站点,然后在新内容经过审核和批准后更新实时服务器。

So all is good in the static site world. Or is it? Read my follow-up post on 7 Reasons NOT to Use a Static Site Generator. And for a practical demonstration of how to build a site with a static site generator, see my How to Create a Static Site with Metalsmith article.

因此,在静态站点世界中一切都很好。 还是? 阅读有关不使用静态网站生成器的7个原因的后续文章。 有关如何使用静态站点生成器构建站点的实际演示,请参阅我的如何使用Metalsmith创建静态站点文章。

翻译自: https://www.sitepoint.com/7-reasons-use-static-site-generator/

编辑器生成静态网页

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_785177.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

wordpress 自定义_为您的WordPress网站设计自定义主页

wordpress 自定义WordPress is used on a large portion of sites on the web. It allows us to create a variety of different types of sites, but one of the most important components of any website is always the home page. The perfect landing page will help you …

编辑器生成静态网页_不使用静态网站生成器的7个理由

编辑器生成静态网页Trending posts on SitePoint today: 今天在SitePoint上的热门帖子: 7 Ways to Make WordPress Simpler for Users 为用户简化WordPress的7种方法 I Need a Website. What Do I Need to Know About Hosting? 我需要一个网站。 关于托管我需要了…

wordpress插件_审查的顶级WordPress SEO插件

wordpress插件WordPress provides great native SEO features, so might your theme. However, by using a dedicated SEO plugin (and knowing how to use it) we can further optimize our site. In this article we compare the top SEO plugins for WordPress side-by-side…

如何安装和使用WP-CLI来管理WordPress网站

Speeding up your work process should be one of your top priorities. Simply put, if you do more work in less time, then you will have more time to work on more projects, study and rest. 加快工作流程应该是您的首要任务之一。 简而言之,如果您用更少的…

wordpress快速建站_快速提示:使用WordPress联络表7增强选择加入

wordpress快速建站You might have heard the saying, “the money is in the list”. Your email list, to be exact. Email marketing is widely considered to be the most powerful form of marketing today, and there are plenty of stats to back it up. 您可能已经听说过…

php网站功能块学习_学习PHP 7,了解新功能等

php网站功能块学习PHP 7, the next version of the world’s most popular programming language, has been released. We’d love to shoot fireworks and get drunk with our newfound power (seriously, the language is in the true big leagues now, functionality and pe…

wordpress网站迁移_如何将您的WordPress网站迁移到新的托管服务提供商

wordpress网站迁移This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 We’ve be…

wordpress 静态化_地理定位WordPress内容以个性化您的网站

wordpress 静态化So what does that phrase mean, “Geo-Targeting WordPress Content”? First, let’s back up and look at an example of personalization. 那么,这句话是什么意思,“以地理定位的WordPress内容”? 首先,让我…

next主题seo优化_SEO可见性的5个最佳WordPress主题

next主题seo优化This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 Theme selec…

cloudflare_使用Cloudflare使您的网站更快,更安全

cloudflareCloudflare is an industry leader in the content-delivery space, reducing load and speeding up millions of websites. Cloudflare是内容交付领域的行业领导者,可减轻负载并加快数百万个网站的速度。 What is peculiar about this provider is that…

六个最受欢迎的 CMS 建站系统,不容错过|Gitee项目推荐

CMS 是 Content Management System 的缩写,意为"内容管理系统"。 内容管理系统是企业信息化建设和电子政务的新宠,也是一个相对较新的市场。对于内容管理,业界还没有一个统一的定义,不同的机构有不同的理解。CMS 在各行…

html 相对路径 网站根目录,html中的绝对路径URL和相对路径URL及子目录、父目录、根目录...

绝对URL用于表示Internet中特定文件所需要的全部内容,Internet中的每一个文件都有一个唯一的URL,这就是在网页中搜索时需要输入到地址栏的连接。例如,要进入百度一下的网页,则在网页地址栏中输入:即可。一旦进入到某个…

php网站整合ck播放器,网页视频播放器-ckplayer 整合到wordpress

在这里我将教大家怎样将这款播放器整合到wordpress中来,并教大家怎么将优酷视频用到这款播放器上面!第一步:我们要下载一个播放器文件第二步:将下载文件解压出来,打开里面player文件夹下ckplayer.txt文本文档,将里面的…

【最新】某素材网站上的虎年高质量海报素材合集,附带源文件和预览图

原格式PSD提供给大家同时提供jpg预览图,马上过年了,这套素材用的上,红色喜庆 醉了,本来想整理的上传的,但是发现有水印,现在水印已经全部去除,放心食用,每个图都比较大,一…

使用SSM重新开发计科院网站

一、游览 在游览器地址栏输入:http://localhost:8080/index,即访问计科院首页,由于前期对数据库以及JavaBean的设计考虑不够充分,导致后期的代码臃肿,所以项目启动时对首页进行数据的填充难以实现,必须输入…

airpods固件更新方法_AirPods Pro 固件更新,空间音频来了丨 网站证书更新

09/15 网站证书更新 证书已上传,网站福利应用正在更新中…… 福利区已修复完毕,不知道能活多久! 证书已经上传(回复 证书 获取证书下载链接),证书使用教程查看历史文章 【福利升级】iOS苹果端免越狱 手机端签名神器教程来了! 删掉之前的APP再重新下载即可! 证书很不稳…

java程序员语录_「java程序员面试题」2018java程序员面试题整理 - seo实验室

java程序员面试题1.PathVariable注解和requestParam注解的区别。RequestParam注解是获取静态URL传入的参数PathVariable是获取请求路径中的变量作为参数/需要和RequestMAPPing("item/{itemId}") 配合使用2.Param注解和RequestParam注解的区别。Parm 指定request中必…

java webshell_网站漏洞测试 关于webshell木马后门检测

前段时间我们SINE安全收到客户的渗透测试服务委托,在这之前,客户网站受到攻击,数据被篡改,要求我们对网站进行全面的渗透测试,包括漏洞的检测与测试,逻辑漏洞.垂直水平越权漏洞,文件上传漏洞.等等服务项目,在进行安全测试之前,我们对客户的网站大体的了解了一下,整个平台网站,包…

java摄影网站源码_基于jsp的摄影网站-JavaEE实现摄影网站 - java项目源码

基于jspservletpojomysql实现一个javaee/javaweb的摄影网站, 该项目可用各类java课程设计大作业中, 摄影网站的系统架构分为前后台两部分, 最终实现在线上进行摄影网站各项功能,实现了诸如用户管理, 登录注册, 权限管理等功能, 并实现对各类摄影网站相关的实体进行管理。该摄影…

scrapy入门实战-爬取代理网站

相关视频: Python之scrapy入门_哔哩哔哩_bilibili 转:scrapy入门实战-爬取代理网站 - JayMu - 博客园 入门scrapy。 学习了有这几点 1.如何使用scrapy框架对网站进行爬虫; 2.如何对网页源代码使用xpath进行解析; 3.如何书写…