Use Hexo build personal blog 01 - base station articles

Verbatim https://www.dazhuanlan.com/2019/08/25/5d625ae568844/


Specific installation methods google own friends ~

start using

Installation yarn

In the cmdnext input

1
 npm install -g  yarn

-gRepresents the global install the plug-in added to the system environment variables manipulation cmdcan be used in any directory yarncommand

Installation Hexo

1
$ yarn add  hexo

Initialization Hexo

Hexo after installation is complete, execute the following command, Hexo new document will specify the desired folder on your document.

1
2
3
$ hexo init <folder>
$ cd <folder>
$ yarn

After finished, your project will generate the following directory structure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
. 
├── node_modules // dependent on the installation directory
├── scaffolds // template document folder, create a new document from the article directory will inherit the format
| ├── draft.md // draft template
| ├── page. md // page templates
| └── post.md // article template
├── source // resource file folder for placing pictures, data, articles and other resources
| └── _posts // article directories
├── themes / / theme documentation folder
| └── landscape // default theme
├── .gitignore // specified are not included in the document git version control
├── _config.yml // site configuration file
├── db.json
├── Package Penalty for. json
└── the Yarn-lock.json

Here you have completed all of the preparatory work, only one command to start your blog

Local preview Hexo

In turn enter the next project directory

1
2
3
$ HEXO Cl        
$ HEXO G
$ HEXO S # local preview start server default port 4000

After a successful, visit http: // localhost: 4000 / start your preview

hexo Preview

If the port is occupied want to customize a new port or want to start Debug mode again how to do?
hexo s start command has additional parameters
-p [port number] modify the port number
-debug debug mode is turned on

1
$ HEXO S -P [port number] --debug

Deployment Hexo

We write more blog or want to share with the local self-hey how can do it, it must be deployed to the server you ~ There are two ways you can deploy our blog

  • Use github or coding of pages service
  • Deployed on their VPS

    github deployment

Open GitHub , to create a new Repository
Repository name must to [your user name] .github.io
your local public key bindings on github, if not already generated public key ssh, execute the following command to generate a new public key :

1
$ ssh-keygen

If the Windows operating system,
this time will be in C: Documents id_rsa generate the key and public key documents id_rsa.pub under UsersUsername.ssh directory.

Click on the upper right corner on github picture settings / SSH and GPG keys,
create a new SSH key, you will copy the contents of id_rsa.pub to key in the document

new SHH key

Set in the site configuration file in _config.yml

_config.yml
1
2
3
4
5
6
7
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo:
github: [你的github仓库地址]
branch: master

安装Hexo部署插件

1
$ yarn  add  hexo-deployer-git

在当前目录下打开 cmd输入以下命令 开始部署

1
2
3
$ hexo cl
$ hexo g
$ hexo d

访问 [你的github项目名].github.io 查看是否部署成功

每次启动或者部署输入三个命令很麻烦,可以把这三个命令写入到 package.json

1
2
3
4
"scripts": {
"deploy": "hexo clean && hexo g -d",
"start": "hexo clean && hexo g && hexo s --debug",
}

After just type yarn start(start Preview) yarn deploy(deployment)

VPS deployment

Think about it

Untied opened

Guess you like

Origin www.cnblogs.com/petewell/p/11408857.html