hugo部署到github_切换到Hugo和Netlify

hugo部署到github_切换到Hugo和Netlify_第1张图片

hugo部署到github

I’ve made a few changes here, but hopefully, most of them went unnoticed. As I mentioned before, I’ve been wanting to invest more in my own site and content again. With so much I want to tackle—implementing WebMentions, syndicating book reviews to Goodreads, building a bookmarklet to make it easier for me to save links here—naturally I had to prioritize and put first things first.

我在这里做了一些更改,但是希望其中大多数都不会被注意到。 如前所述, 我一直想在自己的网站和内容上再投资更多 。 我想解决的事情太多了—实现WebMentions,将书评联合到Goodreads,构建书签以使我更容易在这里保存链接—自然,我必须优先考虑并把第一件事放在首位。

So I changed the static site generator I was using as well as the hosting provider.

因此,我更改了我使用的静态站点生成器以及托管提供程序。

It’s actually not as off-track as it sounds. I had been running Jekyll for a long time now, loving the fast loading times. But there were a few issues. The most notable is my own fault: over the years, I had done a poor job of keeping things neat and tidy. The whole setup was pretty unwieldy and messy. It was to the point where I was either going to need to refactor my code anyway or switch it up altogether.

实际上,它并不像听起来那样偏离轨道。 我已经运行Jekyll很长时间了,喜欢快速的加载时间。 但是有一些问题。 最明显的是我自己的错:多年来,我在使事情保持整洁方面做得很差。 整个设置非常笨拙且混乱。 到了这一点,我要么仍然需要重构我的代码,要么将其完全切换。

The second issue was that while the site was fast to load, it was pretty slow to generate. It was enough of an annoyance that I decided if I was going to be making changes anyway, I might as well find something fast.

第二个问题是,虽然网站加载速度很快,但生成速度却很慢。 我决定是否要进行更改已经很烦人了,我不妨快点找到一些东西。

I didn’t do much looking around, either. I remembered reading a post by Sara Soueidan about how she migrated from Jekyll to Hugo so I started there.

我环顾四周也没做什么。 我记得曾经读过萨拉·索伊丹(Sara Soueidan)的一篇关于她如何从杰基尔(Jekyll)迁移到雨果(Hugo)的文章,所以我从那里开始。

The templating syntax Hugo uses isn’t altogether that different from the liquid templating used by Jekyll. It was different enough to cause me to hit my head against the wall at first but similar enough that porting the theme over to Hugo didn’t take a lot of time.

Hugo使用的模板语法与Jekyll使用的液体模板完全没有区别。 差别足以使我一开始就撞墙,但足够相似,因此将主题移植到Hugo并不需要花费很多时间。

The migration was smooth enough. The Hugo docs are a little clunky, but Sara’s post was a life-saver. If you’re moving from Jekyll to Hugo, that’s where I’d suggest you start.

迁移足够顺利。 Hugo的文档有些笨拙,但Sara的职位是救生员。 如果您要从杰基尔搬到雨果,那就是我建议您开始的地方。

I couldn’t do a better job of explaining the switch than Sara did, so I won’t even try. I will, however, highlight two things that I consider the killer features of Hugo.

我不能比Sara更好地解释切换,所以我什至不会尝试。 但是,我将重点介绍两件事,我认为这是雨果的杀手features。

The first: it is fast. Generating a new version of the site is almost instantaneous. It’s night and day from the experience of generating my Jekyll based site.

第一: 速度很快 。 生成站点的新版本几乎是瞬间的。 生成我的基于Jekyll的网站的经验是白天和黑夜。

The other thing I like about Hugo is how it handles different content types. On this site, I have blog posts, saved links, talks, book reviews (now) and static pages. For each content type, I can set an archetype. The archetype is a starting point for the structured data used by each type of content.

我喜欢Hugo的另一件事是它如何处理不同的内容类型。 在此站点上,我有博客文章,已保存的链接,演讲,书评(现在)和静态页面。 对于每种内容类型,我可以设置一个原型 。 原型是每种内容使用的结构化数据的起点。

For example, my saved links have the following data fields:

例如,我保存的链接具有以下数据字段:

- externalURL
- date
- title
- tags

My talks have a different setup:

我的演讲有不同的设置:

- startDate
- endDate
- title
- conferenceLink
- talkTitle
- location

Hugo lets you create a markdown file for each that contains YAML data structured the way that content type requires. Here’s my archetype file for my saved links:

Hugo让您为每个包含内容类型要求的YAML数据的markdown文件创建一个markdown文件。 这是我保存的链接的原型文件:

---
date: "{{ .Date }}"
title: "{{ replace .TranslationBaseName "-" " " | title }}"
externalURL:
tags:
---

Now if I want to create a new saved link, I can run hugo new saved/my-new-link.md. Hugo will see that the content type is “saved” (defined by the directory structure here) and use the archetype I’ve defined to get the metadata in place. The date and title will be auto-populated (that’s what the funky stuff in the brackets do), and the rest will be empty and waiting for me fill in. It makes setting up different content types an absolute breeze.

现在,如果我想创建一个新的保存的链接,可以运行hugo new saved/my-new-link.md 。 Hugo将看到内容类型是“保存的”(在此由目录结构定义),并使用我定义的原型将元数据放置到位。 日期和标题将自动填充(这就是括号中的时髦内容),其余部分将为空,等我填写。这使设置不同的内容类型变得轻而易举。

试着Netlify (Taking Netlify for a spin)

Switching to Hugo let me start with a clean slate. With my now neat and tidy repo ready to roll, I decided to take the opportunity to give Netlify a try as well.

切换到雨果让我从一个干净的开始。 在准备好我现在整洁的回购协议后,我决定趁此机会尝试Netlify 。

I had been hosting using Digital Ocean (who I still love and use for many other sites), but I had heard so many folks raving about Netlify’s simplicity. Also, Phil Hawksworth recently joined the team and I welcome any excuse I can get to bother Phil.

我一直在使用Digital Ocean(我仍然爱着并在许多其他网站上使用过)进行托管,但是我听到过很多人热衷于Netlify的简单性。 另外, 菲尔·霍克斯沃思 ( Phil Hawksworth)最近也加入了团队,我欢迎可以打扰菲尔的任何借口。

There’s not much to say about my setup there. The move to Netlify went without much of a hitch (once I set the HUGO_VERSION environmental variable). Netlify monitors my Github repo and when I push a change to the master branch, Netlify kicks off a quick deploy process. Netlify uses Let’s Encrypt, so getting HTTPS in place is a breeze.

关于我的设置没有太多要说的。 迁移到Netlify的过程很顺利(一旦我设置了HUGO_VERSION环境变量)。 Netlify监视我的Github存储库,当我将更改推送到master分支时,Netlify开始快速部署过程。 Netlify使用“ 让我们加密” ,因此轻松实现HTTPS是一件容易的事。

At the moment, I’m not doing as much with Netlify as I could. It’s plumbing. Efficient, frictionless plumbing that gets the job done and then gets out of the way. That may not sound glamorous, but to me, that’s the definition of a good tool.

目前,我对Netlify的工作不尽如人意。 水暖 高效,无摩擦的管道可以完成工作,然后再进行处理。 听起来可能并不迷人,但是对我来说,这就是一个好的工具的定义。

At some point, I plan on playing around with some of Netlify’s other features. In particular, the Lambda functions feature (in beta) could end up being pretty useful. I love static-site generators, but as Paul pointed out, they do make some functionality a bit tricky to implement. I’m thinking a few quick Lambda functions may end up coming in handy.

在某个时候,我计划试用Netlify的其他一些功能。 特别地,Lambda函数功能(处于beta中)最终可能会非常有用。 我喜欢静态站点生成器,但是正如Paul指出的那样 ,它们确实使某些功能难以实现。 我在想一些快速的Lambda函数可能最终派上用场。

I don’t see myself using it, but I also like that they do A/B tests on the edge (fancy CDN talk for on a server somewhere). As a performance nut, client-side A/B tests make me weep.

我看不到自己在使用它,但我也喜欢它们在边缘进行A / B测试(花哨的CDN在某处服务器上进行讨论)。 作为性能要点,客户端A / B测试让我大失所望。

The whole switch should’ve been invisible (well, it would’ve had somebody double-checked the default permalinks first). It was also very quick. Mostly that’s because I forced myself not to refactor my code too much, as much as I wanted to.

整个开关应该已经看不到(当然,这能有我们的第一双检查默认固定链接 )。 这也非常快。 通常,这是因为我强迫自己不要过度重构我的代码。

Small steps, but enough to make the process of publishing to my site a much more pleasant experience.

很小的步骤,但足以使发布到我的网站的过程变得更加愉快。

翻译自: https://timkadlec.com/remembers/2018-02-01-switching-to-hugo-and-netlify/

hugo部署到github

你可能感兴趣的:(java,python,机器学习,编程语言,人工智能)