编辑器生成静态网页

tech2023-02-21  97

编辑器生成静态网页



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 Version Control with Git

使用Git的WordPress版本控制

10 Easy WordPress Security Tips

10个简单的WordPress安全提示

What Is the Right Image Format for Your Website?

什么是您网站的正确图像格式?



In my previous article we discussed reasons why you could benefit from using a static site generator. To recap:

在上一篇文章中,我们讨论了为什么可以从使用静态网站生成器中受益的原因。 回顾一下:

A static site is a collection of pages contained in basic HTML files. You could hand-write these in a text editor, but managing assets and repeated elements such as navigation can become problematic.

静态站点是基本HTML文件中包含的页面的集合。 您可以在文本编辑器中手写这些内容,但是管理资产和诸如导航之类的重复元素可能会出现问题。

A content management system (CMS) stores page content in a database and provides facilities to edit and apply themes. Management becomes easier at the expense of flexibility, performance, server requirements, security and backups.

内容管理系统 (CMS)将页面内容存储在数据库中,并提供了编辑和应用主题的工具。 以灵活性,性能,服务器要求,安全性和备份为代价,管理变得更加容易。

A static site generator (SSG) is a compromise between using a hand-coded static site and a full CMS. You generate an HTML-only website using raw data (such as Markdown files) and templates. The resulting build is transferred to your live server.

静态站点生成器 (SSG)是使用手动编码的静态站点和完整CMS之间的折衷方案。 您使用原始数据(例如Markdown文件)和模板生成仅HTML的网站。 生成的构建将传输到您的实时服务器。

Popular static site generators include Jekyll, Pelican, Hugo and Metalsmith — see StaticGen for many more options.

流行的静态站点生成器包括Jekyll , Pelican , Hugo和Metalsmith-有关更多选项,请参见StaticGen 。

SSGs appear to offer the benefits of both CMS and static worlds, but they will not be suitable for every project …

SSG似乎可以同时提供CMS和静态世界的好处,但是它们并不适合每个项目……

1.你自己动手 (1. You’re On Your Own)

You won’t get far using a static site generator without some development expertise. The process is more difficult than using a CMS, there are fewer reference resources, and you could struggle to find pre-built plugins and templates.

如果没有一些开发专业知识,使用静态站点生成器将无济于事。 该过程比使用CMS更加困难,参考资源更少,并且您可能很难找到预构建的插件和模板。

Contrast that with WordPress. A non-technical user may require installation assistance but, once done, they can edit a site and install one of the many thousands of themes and plugins available. They may not have the best bespoke website, but they’re running with minimal intervention.

与WordPress对比。 非技术用户可能需要安装帮助,但是一旦完成,他们就可以编辑站点并安装可用的数千个主题和插件之一。 他们可能没有最好的定制网站,但运行时干预最少。

2.选择麻痹 (2. Choice Paralysis)

There are many static site generators, but even the most popular tools are used by a tiny proportion of the web community. You’ll need time to research, investigate and evaluate the options. The undisputed champion is Jekyll but, while you don’t necessarily require Ruby expertise, it will help if you’ve used the language before.

静态站点生成器很多,但即使是最流行的工具,也很少被Web社区使用。 您将需要时间来研究,调查和评估这些选项。 毫无疑问,冠军是Jekyll,但是虽然您不一定需要Ruby专业知识,但是如果您以前使用过该语言,它将有所帮助。

There are many CMSs, but there’s one obvious choice: WordPress. It powers more than one in every four websites, so help is abundant. Again, it will help if you have some PHP experience, but even a non-developer can create a reasonable website using off-the-shelf themes and plugins.

CMS众多,但有一个显而易见的选择: WordPress 。 它每四个网站中就有一个以上,因此帮助非常丰富。 同样,如果您有一定PHP经验,它也会有所帮助,但是即使是非开发人员也可以使用现成的主题和插件来创建一个合理的网站。

3.初始设置时间 (3. The Initial Setup Time)

Creating your first static site will take time. You’ll need to learn the build process, and much of the template code will need to be developed. Deployment scripts may also be necessary.

创建您的第一个静态站点将需要一些时间。 您将需要学习构建过程,并且将需要开发许多模板代码。 部署脚本也可能是必需的。

Developing a custom CMS theme can also be complicated, but pre-built templates are available and assistance is easier to find. File deployment is rarely required following the initial installation.

开发自定义CMS主题也可能很复杂,但是可以使用预构建的模板,并且更容易找到帮助。 初始安装后很少需要文件部署。

4.没有管理界面 (4. No Administration Interface)

Clients may be cautious when faced with a CMS interface. Asking them to create and edit a set of Markdown files may terrify many. You can make the process easier. For example:

面对CMS界面时,客户端可能会很谨慎。 要求他们创建和编辑一组Markdown文件可能会使许多人感到恐惧。 您可以使过程更容易。 例如:

allow them to use their existing CMS, or

允许他们使用现有的CMS,或者

provide simpler workflows such as editing Dropbox files in StackEdit.

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

But this will further impact your initial development time.

但这将进一步影响您的初始开发时间。

5.网站一致性 (5. Website Consistency)

Static sites are flexible: anything contained within source Markdown files can be rendered as page content. Users may be able to include scripts, widgets or numerous undesired items.

静态站点非常灵活:源Markdown文件中包含的所有内容都可以呈现为页面内容。 用户可能可以包括脚本,小部件或许多不希望的项目。

A CMS constrains the user, because content is normally bound to a database with specific fields. Control panels prompt the user so it’s obvious they must enter a title, body content, excerpt etc. Even if the user enters something in an unexpected field, it won’t appear on the website unless it’s implemented within the theme template.

CMS限制了用户,因为内容通常绑定到具有特定字段的数据库。 控制面板会提示用户,因此很明显他们必须输入标题,正文内容,摘录等。即使用户在意外字段中输入内容,除非在主题模板中实现,否则该内容也不会出现在网站上。

6.管理大型站点 (6. Managing Large Sites)

Consider a website with thousands of pages, regular publications, real-time breaking news and dozens of authors in multiple locations. SitePoint is a great example. It would be possible to manage content using a static site generator, but:

考虑一个拥有成千上万个页面,常规出版物,实时突发新闻以及多个位置的数十位作者的网站。 SitePoint是一个很好的例子。 可以使用静态站点生成器来管理内容,但是:

content editing and publishing is more awkward. Editors may require access to the Git repo or shared folders rather than a simple web or app interface.

内容编辑和发布比较麻烦。 编辑者可能需要访问Git存储库或共享文件夹,而不是简单的Web或应用程序界面。 real-time updates would be delayed because the site must be rebuilt, tested and deployed

由于必须重新构建,测试和部署站点,因此实时更新将被延迟 build times could increase rapidly and deployment would become cumbersome.

构建时间可能会Swift增加,并且部署会变得很麻烦。

Static site generators are perhaps best suited to sites containing no more than a few hundred pages with a couple of new posts every week. Automated build and deploy processes will be required, and you may reach a point where a CMS becomes a more practical option.

静态网站生成器也许最适合每周访问几篇新文章的页面不超过几百页的网站。 将需要自动化的构建和部署过程,并且您可能会达到使CMS成为更实用的选择的地步。

7.具有服务器端功能的站点 (7. Sites with Server-side Functionality)

A true static site cannot offer interactive facilities such as user logins, form filling, search or discussion forums. There are some client-side options such as lunr.js search and Disqus commenting, but your choices will be more limited.

真正的静态站点不能提供交互式功能,例如用户登录,表单填写,搜索或论坛。 有一些客户端选项,例如lunr.js搜索和Disqus评论 ,但您的选择将受到更多限制。

There are solutions such as using a build step which generates a static site containing necessary <?php ... ?> code blocks. This should pre-render HTML where possible, e.g. navigation, includes, partials, etc. to ensure pages are more efficient and require less effort from the PHP processor. Unfortunately, you’re increasing the build complexity, and it may be of little benefit to some frameworks.

有一些解决方案,例如使用构建步骤来生成包含必要的<?php ... ?>代码块的静态站点。 这应该在可能的情况下预渲染HTML,例如导航,包含,部分等,以确保页面更高效,并且需要PHP处理器花费更少的精力。 不幸的是,您正在增加构建的复杂性,这对某些框架可能没有什么好处。

静态网站适合您吗? (Is a Static Site Right For You?)

Before making any decision, examine:

在做出任何决定之前,请检查:

your project requirements, size, complexity, etc.

您的项目要求,规模,复杂程度等。 your userbase

您的用户群 your team’s development skills, and

您团队的开发技能,以及 the hosting and/or deployment factors.

托管和/或部署因素。

The vast majority of websites rarely exceed a few dozen pages, receive infrequent updates and depend on a developer to make those changes. A CMS is often overkill, and static site generation could ease development and reduce costs. However, persuading your client to abandon their CMS administration panels could be a tougher task …

绝大多数网站很少超过几十个页面,很少收到更新,并且依赖开发人员进行这些更改。 CMS通常是多余的,静态站点生成可以简化开发并降低成本。 但是,说服您的客户放弃其CMS管理面板可能是一项艰巨的任务……

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.

有关如何使用静态网站生成器构建网站的实际演示,请参阅我的如何使用Metalsmith创建静态网站 。

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

编辑器生成静态网页

相关资源:html静态页面生成
最新回复(0)