buster源

tech2023-08-02  105

buster源

If we were in the mid 2000s, the unanimous choice to start a blog would have been WordPress or Blogger. The last few years have seen a rise in the number of blogging platforms, making this a great time for someone who likes to experiment. One such option, that was released to the public late last year, is Ghost.

如果我们处于2000年代中期,那么创建博客的一致选择就是WordPress或Blogger 。 过去几年中,博客平台的数量有所增加,这对于喜欢尝试的人来说是一个绝佳的时光。 去年年底向公众发布的一种这样的选项是Ghost 。

The best part about Ghost is the support for Markdown — which lets you focus on writing. However, if you are still skeptical, you should look at David Blane’s comparison of Ghost’s features to the big three.

关于Ghost的最好的部分是对Markdown的支持-让您专注于写作。 但是,如果您仍然持怀疑态度,则应查看David Blane对Ghost功能与三大功能的比较 。

If you agree that you should give Ghost a try, there is a small hiccup. If you want to use Ghost.org for hosting your blog, the basic plan starts at $5 per month, restricting you to 10,000 page views (which you can easily reach if your post has a good day on Hacker News). If you download the source code, you would need to host it on a separate server, something that requires some expertise.

如果您同意尝试Ghost,那会有点麻烦。 如果您想使用Ghost.org来托管您的博客,基本计划起价为每月5美元 ,将您的网页浏览量限制为10,000次(如果您的帖子在Hacker News上表现不错,则可以轻松实现)。 如果下载源代码,则需要将其托管在单独的服务器上,这需要一些专业知识。

But we can overcome those issues. In this post, I will show you an easy way to use Ghost for your blog, yet host it for free.

但是我们可以克服这些问题。 在这篇文章中,我将向您展示一个简单的方法来将Ghost用于您的博客,同时免费托管它 。

什么是静态网站? (What are Static Websites?)

A static site is a set of HTML documents or static web pages, nothing more, nothing less. It means that irrespective of the user requesting the site, the content would remain the same. On the contrary, for a dynamic site, the same URL might show different content to different users (for example, https://twitter.com would show me something entirely different to what it would show you, assuming one of us is logged in).

静态站点是一组HTML文档或静态网页,仅此而已。 这意味着无论用户请求该站点如何,内容都将保持不变。 相反,对于动态网站,相同的URL可能向不同的用户显示不同的内容(例如,假设我们中的一个人登录, https://twitter.com将向我显示与向您显示的内容完全不同的内容。 )。

A static website is often cheap or free to host as compared to a dynamic website. But, to generate and update a static site, you would need some specific skills. Unless, of course, you have Buster.

与动态网站相比,静态网站通常便宜或免费托管。 但是,要生成和更新静态网站,您需要一些特定技能。 当然,除非您拥有Buster 。

什么是克星? (What is Buster?)

Buster is a “brute force static site generator for Ghost” (get it?). Buster lets you preview the generated static blog and deploy to GitHub for hosting your site. It’s written in Python and it’s easy to install. You can either download through pip or clone the repository and install.

Buster是“用于Ghost的暴力静态站点生成器”( 明白吗? )。 Buster让您可以预览生成的静态博客,并将其部署到GitHub以托管您的网站。 它是用Python编写的,易于安装。 您可以通过pip下载或克隆存储库并安装。

The process that we will follow is something like this:

我们将遵循的过程是这样的:

Generate static pages from a Ghost site using brute force

使用蛮力从Ghost网站生成静态页面 Preview them using Buster (optional)

使用Buster预览它们(可选) Deploy to our server (like GitHub Pages)

部署到我们的服务器(如GitHub Pages)

使用GitHub Pages托管您的静态网站 (Using GitHub Pages to Host Your Static Website)

GitHub lets you host your static pages for free through GitHub Pages. Any repository you have on GitHub can be configured to provide a preview on the web. All you need to do is create a branch called gh-pages and your repository is accessible at username.github.io/repository-name, where you replace username and repository-name with their respective values.

GitHub允许您通过GitHub Pages免费托管静态页面。 您在GitHub上拥有的任何存储库都可以配置为在Web上提供预览。 您需要做的就是创建一个名为gh-pages的分支,您的存储库可通过username.github.io/repository-name访问,在其中您可以将username和repository-name替换为其各自的值。

There are many alternatives to GitHub Pages, one of which is My.DropPages an unofficial Dropbox application. Although Buster is configured to push to GitHub pages, you can always stop at just generating the static site and manually upload it somewhere else. In this post, we will continue with the assumption that you are going to upload your website to GitHub Pages.

GitHub Pages有很多替代方案,其中之一是My.DropPages一个非官方的Dropbox应用程序。 尽管Buster被配置为推送到GitHub页面,但是您始终可以停止生成静态站点并将其手动上传到其他地方。 在本文中,我们将继续假设您要将您的网站上传到GitHub Pages。

将自定义子域添加到GitHub Pages (Adding a Custom Subdomain to GitHub Pages)

If you need a domain to point to your GitHub Pages repository, you need to add a CNAME record in your domain’s DNS file. For such a blog, you would need to add a CNAME record for the desired subdomain with the value username.github.io.

如果您需要一个域来指向GitHub Pages存储库,则需要在域的DNS文件中添加一个CNAME记录 。 对于这样的博客,您需要为所需的子域添加一个CNAME记录,其值为username.github.io 。

Next, you would need to add a file named CNAME to your repository. The content of the file is simply the string my_subdomain.my_domain.com (again replacing the values with your actual subdomain and domain).

接下来,您需要向存储库添加一个名为CNAME的文件。 文件的内容只是字符串my_subdomain.my_domain.com (再次用您的实际子域和域替换值)。

如何使用Buster (How to use Buster)

The various commands are as follows, which may be used in a roughly chronological order:

各种命令如下,可以按时间顺序大致使用:

buster setup [--gh-repo=<repo-url>] — Makes a static/ directory and initializes a Git repository inside it. You should have a basic repository set up on GitHub.

buster setup [--gh-repo=<repo-url>] -创建一个static/目录并初始化其中的Git存储库。 您应该在GitHub上建立一个基本存储库。

buster generate [--domain=<local-address>] — Generates pages from a local running instance (or overwrites the existing pages). The local address is usually 127.0.0.1:2368.

buster generate [--domain=<local-address>] -从本地运行实例生成页面(或覆盖现有页面)。 本地地址通常是127.0.0.1:2368 。

buster preview — Previews the local static site at localhost:9000.

buster preview —预览本地静态站点localhost:9000 。

buster add-domain [domain-name] — Adds the custom domain or subdomain to the CNAME in your repository.

buster add-domain [domain-name] -将自定义域或子域添加到存储库中的CNAME。

buster deploy — Pushes your changes to GitHub. This is done through the https protocol, and you need to enter your GitHub username and password.

buster deploy -将您的更改推送到GitHub。 这是通过https协议完成的,您需要输入GitHub用户名和密码。

Note: You should run these commands just outside the static directory. If you run them in a different directory managed by Git, the generate command would create a static folder and commit the files in your existing repository.

注意:您应该在static目录外部运行这些命令。 如果您在由Git管理的其他目录中运行它们,那么generate命令将创建一个静态文件夹并在现有存储库中提交文件。

向您的静态页面添加评论 (Adding Comments to Your Static Pages)

One downside of a static website is the inability to add comments. However, third-party services like Disqus only require you to insert a <script> tag, which gets you a comment box. Disqus recognizes the URL from which the request is generated and automatically saves the comments to the relevant thread.

静态网站的一个缺点是无法添加评论。 但是, Disqus等第三方服务仅要求您插入<script>标记,该标记会为您提供一个注释框。 Disqus识别出从中生成请求的URL,并自动将注释保存到相关主题。

To insert the Disqus comment system on your static site, you need to insert it in the Ghost template, from which the static site is generated. Once you register with Disqus, you’ll be provided with a code snippet to insert on your site.

要在您的静态站点上插入Disqus评论系统,您需要将其插入到Ghost模板中,从该模板中生成静态站点。 在向Disqus注册后,您将获得一个代码片段,可插入您的网站。

Find the file post.hbs in the theme directory in Ghost (typically /content/themes/[theme_name]/post.hbs) and paste it in between {{/post}} and </article>. For more information, you could look at a detailed help page on Disqus regarding its installation on Ghost sites. If you have done this correctly, Disqus should appear on your local site, and Buster would extract it automatically.

在Ghost的主题目录(通常为/content/themes/[theme_name]/post.hbs )中找到文件post.hbs ,并将其粘贴在{{/post}}和</article> 。 有关更多信息,您可以查看有关在Ghost站点上安装的Disqus上的详细帮助页面 。 如果操作正确,Disqus应该会出现在您的本地站点上,Buster会自动将其提取出来。

最后的话 (Final Words)

I’d like to end the post with a demo, a blog that I maintain to report my weekly progress in the Google Summer of Code. The static site generated by Buster is available on GitHub.

我想以演示为结尾,并维护一个博客 ,以报告我在Google Summer of Code中的每周进度。 由Buster生成的静态站点可在GitHub上找到 。

What do you think of Buster? Do you know of any alternatives? Let us know in the comments below.

您如何看待巴斯特? 您知道其他选择吗? 在下面的评论中让我们知道。

翻译自: https://www.sitepoint.com/create-static-ghost-blog-buster/

buster源

相关资源:Lishuma-Final-Armbian_5.99_s805_Debian_buster_3.10.108_min.zip
最新回复(0)