Use CHCA to build a static blog

 

 chca is a static blog generator developed with golang. It is simple, convenient and fast. It abandons the need to use commands to compile files every time, and uses file monitoring to compile. The author only needs to put the markdown file in the markdown folder in the configuration. Can automatically generate html.

chca source address:  https://github.com/num5/chca

If you are a novice who doesn't understand programming, chca is more suitable for you. You only need to modify a few configurations to build your own blog. Most importantly, if you don't have your own server, you can build it on github pages for free.

About why start a blog? Check out this article "Why do you want to blog?

There are many tutorials on the Internet about how to build a blog on github, so I won't go into details.

necessary steps

download chca

Windows :http://golune.qiniudn.com/chca-win64.tar.gz

Linux:http://golune.qiniudn.com/chca-linux64.tar.gz

Mac:http://golune.qiniudn.com/chca-darwin64.tar.gz

Download the program corresponding to the platform, create a new folder to store all chca files, and unzip chca to this folder

If you plan to build your blog on github, you also need to download git and apply for a github account

go source installation

go get -v github.com/num5/chca

download chca template

Download address: http://golune.qiniudn.com/default-theme.tar.gz

For template syntax description, please refer to: chca template syntax description

Steps for usage

chca can create a blog with a standalone web server in just two steps

Step 1: Initialize

Open a command terminal and enter and exit the command:

chca init

This step will create  markdown folders and  config.yml files. markdown The folder is used to store the source markdown file of the blog, which config.ymlis the configuration file.

config.ymlThe configuration content is as follows:

# config.yml

# 站点信息
title: 我的网站
subtitle: 网站标题
description: mate-description
keywords: mate-keywords
summary_line: 10 // 首页文章行数
home_art_num: 30 // 首页文章数量

# 文件夹相关
theme: theme/blog //网站模板
markdown: markdown //博客markdown文件存放文件夹
html: /data/www/html //博客html文件存放文件夹
storage: storage //数据存放文件夹,暂时未用到

# 作者信息
author: your name
avatar: /assets/avatar.png  //头像连接,一般放到assets或者avatar文件夹里
github: https://github.com/num5  //github主页
weibo: http://weibo.com/golune  //微博主页
mail: 378999587@qq.com  //email 地址
zhihu: https://www.zhihu.com/people/golune  //知乎主页

# 监听信息配置
paths:  // 监听文件夹
  - markdown
exts:  // 监听后缀名
  - md

# 上传信息
upload_theme: theme/upload  // 上传模版地址

# 自定义标题,可不配置,使用chca设置好的标题
home_title:     //主页标题
archive_title:  //文章归档标题
tag_title:      //标签导航页面标题
cate_title:     //分类导航页面标题
about_title:    //简历页面标题
article_title:  //文章标题标头

Modify the configuration file according to your needs

After initialization, you need to create a theme folder in the same directory as the config.yml file to store the template files

Step 2: Run chca

chca run [port]

Open the chca service, this step automatically opens the listener and built-in webserver, the default webserver port 9900, the port can be customized, the browser   can access the blog by entering http://localhost:9900 .
The listener listens for  filesmarkdown with a  suffix in the folder, which can be configured (refer to the configuration in the previous step ). When the md file in the markdown folder changes, the compilation command will be triggered, and the markdown file will be automatically compiled to generate a static page..md监听信息配置

other commands

Create a new markdown file

chca new filename

The markdown file needs to  --- start with:

---
date: 2017-01-01
title: 我的第一篇博客
categories:
- 技术
tags:
- golang
- chca
---

It is recommended to use the  chca new command to create the markdown file

about.mdThe file is the file that stores the author's resume and is stored in the markdown folder. In addition, readme.md and about.md will not be parsed by the article parser.

Generate static pages

chca complate (或chca c)

This command is used to compile markdown files to generate static html pages

Enable file listener

chca watch (或者chca w)

Turn on the file listener, and configure the listening folder and file suffix in config.yml

Open internal server

chca http [port]

Open the internal server, the port is optional, the default listening port is 9900


Markdown syntax reference link:  Markdown syntax description (Simplified Chinese version)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326351641&siteId=291194637