jekyll是什么
I’ve been using WordPress for the last eight years or so and, along the way, it’s been a good companion. But it’s far from perfect. Over the last four years, while running a high-traffic blog about video games, I struggled with a range of problems, like:
在过去的八年左右的时间里,我一直在使用WordPress,一直以来,它一直是一个很好的伴侣。 但这远非完美。 在过去的四年中,在运行有关视频游戏的高流量博客时,我遇到了一系列问题,例如:
My blog loading slowly. 我的博客加载缓慢。 My blog crashing during peak periods. 我的博客在高峰时段崩溃了。 My blog becoming infected with malware. 我的博客感染了恶意软件。It’s not like I didn’t prepare for these things. I installed W3 Total Cache, setup a content delivery network, upgraded the hosting, installed a number of security plugins, and did all of the “best practices” stuff.
好像我没有为这些事情做准备。 我安装了W3 Total Cache,设置了内容交付网络,升级了主机,安装了许多安全插件,并完成了所有“最佳实践”工作。
Did these things help? Sure, but it was never enough, so when I shut down the site and no longer needed one of WordPress’ biggest advantages – being able to publish content quickly – I decided to look elsewhere.
这些东西有帮助吗? 当然,但这还远远不够,所以当我关闭网站并不再需要WordPress最大的优点之一–能够快速发布内容时-我决定将目光转向其他地方。
Jekyll, I discovered, was exactly what I needed.
我发现Jekyll正是我所需要的。
Jekyll is a static blog generator. This means, instead of installing server-side software that’s built with a language like PHP, you use the command line on your local computer to generate static files (HTML, CSS, etc).
Jekyll是静态博客生成器。 这意味着,您无需安装使用PHP之类的语言构建的服务器端软件,而是使用本地计算机上的命令行生成静态文件(HTML,CSS等)。
These files are generated based on:
这些文件基于以下内容生成:
A configuration file. 配置文件。 Any templates you want to define. 您要定义的任何模板。 Markdown files for blog posts. 博客文章的Markdown文件。You then upload the generated files to any web server and, well, that’s your blog. While this might simply sound like a geeky alternative to WordPress, this static approach has a range of real-word advantages over WordPress.
然后,您将生成的文件上载到任何Web服务器,这就是您的博客。 尽管这听起来像是WordPress的怪异替代品,但这种静态方法比WordPress具有一系列实词优势。
Let’s talk about them.
让我们谈谈他们。
These days, WordPress is basically a content management framework. It can do just about everything and, if that’s what you’re looking for, then stick with it. I haven’t got a vendetta against WordPress. It’s great software. It’s just evolved beyond its roots and beyond what I (and many other people) need.
如今,WordPress基本上是一个内容管理框架。 它几乎可以做所有事情,如果这就是您想要的,那就坚持下去。 我没有针对WordPress的仇杀者。 这是很棒的软件。 它的发展超出了它的根源,超出了我(和许多其他人)的需求。
Jekyll, by comparison, is just a blogging platform. To some, this focus will be limiting, but if you only want to run a blog, then:
相比之下,Jekyll 只是一个博客平台。 在某些情况下,这种关注将受到限制,但是如果您只想运行博客,则:
Jekyll has everything you need and nothing that you don’t. You won’t be bogged down in options and insignifcant choices, but you also won’t lack the features you need most.
Jekyll拥有您所需的所有东西,而没有您不需要的东西 。 您不会被选项和微不足道的选择所困扰,但是您也不会缺少最需要的功能。
The writing experience is unparalleled. Because your content is built with Markdown files, you can use whatever text editor you prefer. Personally, I use Sublime Text, but any other option is fine. Your preference wins.
写作经验无与伦比 。 由于您的内容是使用Markdown文件构建的,因此您可以使用任何喜欢的文本编辑器。 就个人而言,我使用Sublime Text,但其他任何选择都可以。 您的偏好获胜。
There’s less chance of anything breaking. This is partly because of Jekyll’s small scope allowing for a considerable amount of polish, but also because you’re not dealing with finnicky server-side software.
发生任何事情的可能性都较小 。 部分原因是因为Jekyll的范围很小,可以进行大量抛光,而且还因为您没有在使用finnicky服务器端软件。
The “best” tool will always depend on the context but, increasingly, I think a simpler platform like Jekyll is worthy of being considered first.
“最佳”工具将始终取决于上下文,但越来越多的我认为像Jekyll这样的更简单的平台值得首先考虑。
A few months after launching my blog, a traffic surge saw hundreds of people browsing my blog at the same time. This was it, I thought. My hard work is paying off. Then the blog crashed, and it remained crashed for the next few hours, so what should have been a big day for the blog turned into a ball of stress that made me look like an amateur.
启动我的博客几个月后,流量激增,数百人同时浏览我的博客。 我想是这样。 我的辛勤工作得到了回报。 然后博客崩溃了,并且在接下来的几个小时内崩溃了,所以对于博客来说应该是重要的一天变成了一个压力球,使我看起来像一个业余爱好者。
Of course, WordPress isn’t the only server-side application that’ll have trouble when it receives a large amount of traffic, but there’s more than a few stories of WordPress blogs crashing at precisely the wrong time – even with all of the proper optimizations – and there’s nothing sillier than worrying about your blog becoming too popular.
当然,WordPress并不是唯一一个在接收大量流量时会遇到麻烦的服务器端应用程序,但是有很多故事都说WordPress博客在错误的时间崩溃了,即使所有正确的情况也是如此。优化–担心您的博客变得太受欢迎没有什么比这更傻了。
By switching to Jekyll though, this risk is non-existent:
通过切换到Jekyll,这种风险不存在:
The loading of static files places a tiny amount of load on a server. The amount of load is almost impercetible. You’d have to try hard (or have a really lousy web host) to make your blog crash.
静态文件的加载对服务器的负载很小 。 负载量几乎是难以察觉的。 您必须努力(或拥有一个非常糟糕的Web主机)才能使博客崩溃。
You can host your website on Amazon S3. This makes it near-impossible for your blog to crash since the resources will automatically scale as you use them. There are few better sources of peace of mind.
您可以在Amazon S3上托管您的网站 。 这使您的博客崩溃几乎是不可能的,因为资源将在您使用它们时自动扩展。 几乎没有更好的内心平静来源。
Maybe your blog has never been popular enough to crash from high traffic but, I can assure you, it’s a terrible feeling to put months of work into a blog, only for it to crumble when it gets the attention you’ve been looking for. Preparing for your big day, then, is a very worthwhile investment.
也许您的博客从未流行过,无法因高流量而崩溃,但是,我可以向您保证,将几个月的工作放在一个博客中是一种可怕的感觉,只有当它吸引了您一直在寻找的注意力时,它才会崩溃。 因此,为重要的一天做准备是一笔非常值得的投资。
For the same reasons that WordPress struggles under load, WordPress is slow: it relies on dynamic code and database calls. You can make a WordPress blog load fast, but it’s like trying to optimize the speed of a tortoise. You’re just not starting from the right base.
由于WordPress难以承受负载的相同原因,WordPress速度很慢:它依赖于动态代码和数据库调用。 您可以使WordPress博客加载速度更快,但这就像试图优化乌龟的速度一样。 您只是没有从正确的基础开始。
Optimizing a Jekyll blog, on the other hand, is easy, since you can:
另一方面,优化Jekyll博客很容易,因为您可以:
Host your entire blog on a server running nginx. 将整个博客托管在运行nginx的服务器上。 Minify your HTML and CSS without using a server-side plugin. 缩小HTML和CSS,而无需使用服务器端插件。 Avoid over-complicated caching plugins altogether. 完全避免过度复杂的缓存插件。 Regularly run all of your images through ImageOptim (which I’ve found a lot better than using the SmushIt! plugin). 通过ImageOptim定期运行所有图像(我发现它比使用SmushIt!插件要好得多)。 Have much more direct control over the design of your blog. (WordPress has good support for theming, but Jekyll is less fiddly to get started with.) 对您博客的设计有更多直接控制。 (WordPress对主题提供了很好的支持,但是Jekyll不太喜欢入门。)But even without optimizations, the fact that Jekyll blogs are made of static files is enough to make them load faster than most WordPress blogs. It’s just that, if you go the extra mile, your blogs can load insanely fast. (My blog loads in under a second for most people, and I could take it further.)
但是即使没有优化,Jekyll博客由静态文件组成的事实也足以使它们比大多数WordPress博客加载速度更快。 仅仅是,如果您付出更多努力,您的博客就可以疯狂地快速加载。 (对于大多数人来说,我的博客加载时间不到一秒钟,我可以更进一步)。
The more popular a piece of software it becomes, the more it becomes a target for the unfriendly sort of hacker. Does that mean your WordPress install is a ticking time-bomb and that someone will inevitably mess with it? Nope.
软件变得越流行,就越成为不友好的黑客的目标。 这是否意味着您的WordPress安装是一个定时的炸弹,并且不可避免地会有人搞砸它? 不。
In the last eight years, I can only recall one breach where someone installed malware on my blog when I was a little behind on updating. So considering how easy it is to update WordPres and how many security plugins are now available, it’s not hard to grasp a solid amount of peace of mind.
在过去的八年中,我只能回想起一次漏洞,当时我在更新上稍有落后,有人在我的博客上安装了恶意软件。 因此,考虑到更新WordPres的难易程度以及现在有多少个安全性插件可用,不难掌握很多内容。
That said:
说:
Having “lots” of peace of mind is not the same as having total peace of mind, and as someone who’s dealt with intrusions outside of WordPress, it’s a painful enough process that I’d rather avoid it entirely if I could.
塌实的“手”是不一样的有高枕无忧的生活,和人谁是涉及入侵的WordPress之外,这是一个痛苦的足够的过程,我宁愿避免它完全如果我能。
Security is not just the ability to protect from attacks, but also having the ability to quickly recover from anything that might go wrong. 安全不仅是防御攻击的能力,而且还具有从可能出现问题的地方快速恢复的能力。The advantage of Jekyll is that, on the server, there’s only static files. There’s nothing dynamic that can be exploited. Are there other ways a hacker could break into your site? Sure. But only through the ever-present threats, like someone getting the username and password for your server. There’s no risk of a hacker breaking in through an exploit in a poorly written plugin or through a problem within Jekyll itself.
Jekyll的优点是在服务器上只有静态文件。 没有动态可以利用。 黑客还有其他方法可以入侵您的网站吗? 当然。 但是只有通过不断出现的威胁,例如有人才能获取服务器的用户名和密码。 不会有黑客通过编写不良的插件中的漏洞或通过Jekyll本身中的问题闯入黑客的风险。
If an attack does occur, or if there’s “just” some data loss for some other reason, then the recovery process couldn’t be simpler:
如果确实发生了攻击,或者由于其他原因“仅”丢失了某些数据,那么恢复过程就不会再简单了:
Regenerate the blog on your local machine. 在本地计算机上重新生成博客。 Upload it again to the server. 再次将其上传到服务器。If you need a new server, then so be it. There’s nothing “heavy” to move like a database, or anything special to install. Just pay for a new server, upload the files to it, and that’s it. You’re back in action.
如果您需要一台新服务器,那就这样吧。 移动像数据库一样“繁重”,也没有什么特别的安装。 只需购买新服务器,然后将文件上传到该服务器即可。 您又回来了。
In terms of local data loss, it’s another non-issue. Store your Jekyll blog inside your Dropbox folder and it’ll be backed up continually. Throw in a tool like Arq (with Glacier) and your blog’s data will be safer than it probably is at the moment. The cost will also be negligible since static files are so tiny (while still being easy to store them for long durations of time).
就本地数据丢失而言,这是另一个问题。 将您的Jekyll博客存储在Dropbox文件夹中,它将不断进行备份。 使用Arq(与Glacier)等工具,您博客的数据将比目前可能更安全。 由于静态文件非常小(尽管仍然很容易长时间存储它们),因此成本也可以忽略不计。
The catch-all solution for the problems I’ve covered so far is to pay more for web hosting. There are even hosting services like Synthesis that are precisely dedicated to solving these problems and can bring a satisfying level of peace of mind.
到目前为止,针对我所涵盖问题的全面解决方案是为虚拟主机支付更多费用。 甚至还有诸如Synthesis之类的托管服务,这些服务都专门致力于解决这些问题,并且可以使人安心。
But these services come at a cost. Some will argue that “you have to spend money to make money” but that doesn’t always make sense. The struggle with my video game blog, for example, is that the margins were so low. If I spent extra on hosting, it would have been a significant chunk of the revenue. Maybe that’s a sign that something is wrong with the business model itself, but I was running the business how I wanted to run it and the costs were associated with my use of WordPress, rather than being an inherent factor in running the blog.
但是这些服务是有代价的。 有人会说“必须花钱才能赚钱”,但这并不总是有意义。 例如,与我的视频游戏博客的斗争是利润太低。 如果我花更多的钱在托管上,那将是一笔可观的收入。 也许这表明业务模型本身存在问题,但是我按照自己想要的方式来运行业务,而成本却与使用WordPress有关,而不是运行博客的固有因素。
By avoiding these WordPress hosts, and by optimizing the hell out of my blog, I was able to sneak away with a bill of about $60 a month, but the blog would still crash under the (mostly) unpredictable traffic bursts.
通过避免使用这些WordPress主机,并优化博客的地狱,我每月可以偷偷支付约60美元的账单,但是该博客仍然会在(主要是)不可预测的流量爆炸中崩溃。
Compare this to my new, static blog. I could receive 10,000 visitors in the next hour and it wouldn’t flinch, and yet it only costs $5 per month to host on a Digital Ocean droplet (with nginx installed).
将此与我的新静态博客进行比较。 我可以在接下来的一个小时内收到10,000个访问者,它不会退缩,但是每月仅需$ 5即可托管Digital Ocean Droplet(已安装nginx)。
To slice costs even further though, host your blog on Amazon S3. Not only will it scale without limits no matter how much traffic you receive, most people will spend only a couple of bucks for hosting. (The advantage of Digital Ocean is the speed, which is why I fork out the tiny bit of extra money.)
为了进一步削减成本,请在Amazon S3上托管您的博客。 无论您收到多少流量,它都将无限制地扩展,大多数人只花几美元就可以托管。 (Digital Ocean的优势是速度,这就是为什么我会花一点钱赚钱。)
There’s a lot to love about WordPress and, if you find yourself thinking, “But the trade-off isn’t worth it…” in response to any of these points, then you’re probably right, and you should keep using WordPress.
对WordPress有很多爱,并且,如果您发现自己在想:“但是,权衡是不值得的……”,那么回答这些问题时,您可能是对的,您应该继续使用WordPress。
I don’t want to push people onto Jekyll for the sake of it. However, I believe that a lot of bloggers (and a lot of blog readers) stand to gain from switching away from a dynamic blog, so it’s at least worth your consideration.
我不想因此而将人们推向杰基尔。 但是,我相信很多博客作者(和很多博客读者)会从动态博客的切换中受益,因此至少值得您考虑。
翻译自: https://www.sitepoint.com/wordpress-vs-jekyll-might-want-make-switch/
jekyll是什么