Hugo快速搭建Blog

摘要:
不用安装编程语言环境,不用安装数据库,只需要几个步骤就可以快速搭建一个blog出来。1安装---------------------------推荐二进制安装到HugoReleases下载对应的操作系统版本的Hugo二进制文件HugoReleases:https://github.com/gohugoio/hugo/releases本文以Windows为例,所以下载:hugo_0.24.1_Windows-64bit.zip下载之后解压得到“hugo.exe”文件。YournewHugositeiscreatedinD:gitlog.Justafewmorestepsandyou'rereadytogo:1.Downloadathemeintothesame-namedfolder.Chooseathemefromhttps://themes.gohugo.io/,orcreateyourownwiththe"hugonewtheme"command.2.Perhapsyouwanttoaddsomecontent.Youcanaddsinglefileswith"hugonew.".3.Startthebuilt-inliveservervia"hugoserver".Visithttps://gohugo.io/forquickstartguideandfulldocumentation.一个blog站点就创建好了。接下来切换到blog站点目录,创建一篇文章:D:git˃cdblogD:gitlog˃hugonewabout.md该文件位于blog/content/about.md目录下。Hugothemes:https://themes.gohugo.io/你可以到上面的网站中挑选你喜欢的主题。

以往我们搭建blog要么学习一个编程语言+Web开发框架,要么使用现成的blog系统(如WordPress)。其实我们还可以使用Hugo。Hugo是由Go语言实现的静态网站生成器,它不需要数据库,所以页面都是通过MarkDown开发的页面。不用安装编程语言环境,不用安装数据库,只需要几个步骤就可以快速搭建一个blog出来。

1 安装

---------------------------

推荐二进制安装(简单、快速)

Hugo Releases下载对应的操作系统版本的Hugo二进制文件(hugo或者hugo.exe)

Hugo Releases:https://github.com/gohugoio/hugo/releases

本文以Windows为例,所以下载:hugo_0.24.1_Windows-64bit.zip

下载之后解压得到“hugo.exe”文件。

将hugo.exe所在的目录添加到系统环境变量PATH下面,打开cmd,输入“hugo version”。

Hugo快速搭建Blog第1张

2 创建站点&文章

---------------------------------------

想要创建站点,一个命令搞定,切换到你想要创建站点的目录,输入:

D:git>hugo new site blog
Congratulations! Your new Hugo site is created in D:gitlog.
Just a few more steps and you're ready to go:
1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME><FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".
Visit https://gohugo.io/ for quickstart guide and full documentation.

一个blog站点就创建好了。新建的站点目录结果如下:

blog/
    archetypes/ 
    doc/
    content/ 
    data/ 
    layouts/ 
    static/ 
    config.toml

当前的站没有任何内容,也没做任何配置。

接下来切换到blog站点目录,创建一篇文章:

D:git>cd blog
D:gitlog>hugo new about.md

该文件位于 blog/content/about.md目录下。打开编辑:

+++
date = "2017-07-03T15:37:11+08:00"
tags = ["blog"]
title = "my first blog"
+++
### 这里使用markdown来编写文章

markdown 教程:http://wowubuntu.com/markdown/

3 安装主题

---------------------------

站点一定要有主题,安装主题应该是最难的一步了,因为不同的主题设置方式也会有所不同。

Hugo themes:https://themes.gohugo.io/

你可以到上面的网站中挑选你喜欢的主题。然后,根据指引找到github项目地址进行下载。

3.1 下载主题:

我使用的主题是:https://github.com/wd/hugo-fabric

把主题通过git克隆或直接下载到本地。放到 …/blog/themes/目录下。

3.2 使用主题:

生成主题资源文件(hugo-fabric为主题名)

D:gitlog>hugo -t hugo-fabric
Started building sites ...
Built site for language en:
0 of 3 drafts rendered
0 future content
0 expired content
8 regular pages created
12 other pages created
0 non-page files copied
2 paginator pages created
1 tags created
1 categories created
total in 35 ms

将log hemeshugo-fabricexampleSiteconfig.toml 替换 logconfig.toml

注:config.toml文件是核心,对网站的配置多数需要修改该文件,而每个主题的配置又不完全一样。

4 启动服务器

------------------------------

D:gitlog>hugo server
WARNING: Site config's rssURI is deprecated and will be removed in a future release. Set baseName in outputFormats.RSS.
Started building sites ...
Built site for language en:
0 draft content
0 future content
0 expired content
1 regular pages created
8 other pages created
0 non-page files copied
1 paginator pages created
1 tags created
0 categories created
total in 9 ms
Watching for changes in D:gitlog{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

打开浏览器访问:http://localhost:1313/

Hugo快速搭建Blog第2张

用Hugo搭建的网站:http://www.testclass.net/

免责声明:文章转载自《Hugo快速搭建Blog》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Semantic 3DWEB、FTP服务器所有响应码解释(超详细)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

libcurl+openssl实现https爬虫

https图解: 1、客户端向服务端发送SSL协议版本号、加密算法种类、随机数等信息。 2、服务端给客户端返回SSL协议版本号、加密算法种类、随机数等信息,同时也返回服务器端的证书,即公钥证书 3、客户端使用服务端返回的信息验证服务器的合法性,包括: 证书是否过期 发型服务器证书的CA是否可靠 返回的公钥是否能正确解开返回证书中的数字签名 服务器证书上的...

精品 IDEA 插件大汇总!值得收藏

轻松提高 Java 开发效率 俗话说,工欲善其事,必先利其器。想要提升编程开发效率,必须选择一款顺手的开发工具。 对于 Java 开发者,JetBrains IDEA 无疑是目前最主流的开发工具,既简单易用、又强大灵活,并且可以通过安装插件全副武装。 今天鱼皮汇总了 IDEA 实用插件,分享给大家,希望帮助大家大幅提高开发效率! 插件较多,建议大家先观看...

多级代理 haproxy 传递X-Forwarded-Proto

有时候后端需要知道客户端是用的http请求还是https请求,所以一般在haproxy加上一个X-Forwarded-Proto头 http-request set-header X-Forwarded-Proto http if !{ ssl_fc } http-request set-header X-Forwarded-Proto https if...

hcharts实现堆叠柱形图

<!DOCTYPE > <html> <head> <meta charset="utf-8"><link rel="icon" href="https://static.jianshukeji.com/highcharts/images/favicon.ico">...

HTTPS学习之教你弄透到底什么是HTTPS

本文谈谈我的看法,主要分为以下几个方面: HTTPS 协议是什么? HTTPS 是如何工作的? HTTPS 真的安全吗? 一、什么是 HTTPS HTTPS,也称作 HTTP over TLS,TLS 前身是 SSL,会有各个版本。TLS 协议在 TCP/IP 协议栈中的关系如下: 上图描述了在 TCP/IP 协议栈中 TLS(各子协议)和 HTTP...

【hbase】【windows】安装及启动

参考文章:https://www.jianshu.com/p/db33aaa566cd 由于担心这么好的文章可能被删除等原因,所有一下基本都复制内容过来 1、环境、安装包等 JDK1.8.0_192(下载地址:https://www.oracle.com/java/technologies/javase/javase8-archive-downloads....