浅谈hexo博客-01安装hexo与建立网站

安装的前置条件

  • git
  • nodejs

git安装

brew install git

nodejs

brew install node

安装hexo

npm install -g hexo-cli

初始化建站

hexo init
cd
npm install

具体的目录为以下结构


├── _config.yml
├── package.json
├── scaffolds
├── source
|   ├── _drafts
|   └── _posts
└── themes

scaffolds

模版 文件夹。当您新建文章时,Hexo 会根据 scaffold 来建立文件。

Hexo的模板是指在新建的markdown文件中默认填充的内容。例如,如果您修改scaffold/post.md中的Front-matter内容,那么每次新建一篇文章时都会包含这个修改。

source

资源文件夹是存放用户资源的地方。除 _posts 文件夹之外,开头命名为 _ (下划线)的文件 / 文件夹和隐藏的文件将会被忽略。Markdown 和 HTML 文件会被解析并放到 public 文件夹,而其他文件会被拷贝过去。

themes

主题 文件夹。Hexo 会根据主题来生成静态页面。

hexo配置

看_conflg.yml

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: The CnSkyline‘s Blog
subtitle: when technology becomes absolute passion!
description: the blog of personal technology and some pitures.
keywords:
author: King_Alex
language: chinese
timezone: UTC

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url:xxxx
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

# Directory
source_dir: source         #资源文件夹,这个文件夹用来存放内容
public_dir: public         #公共文件夹,这个文件夹用于存放生成的站点文件
tag_dir: tags              #标签文件夹
archive_dir: archives      #归档文件夹
category_dir: categories   #分类文件夹
code_dir: downloads/code   #Include code 文件夹
i18n_dir: :lang            #国际化(i18n)文件夹
skip_render:

# Writing
new_post_name: :year-:month-:day-:title.md # File name of new posts
default_layout: post     # 预设布局
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0         #把文件名称转换为 (1) 小写或 (2) 大写
render_drafts: false     #显示草稿
post_asset_folder: false #启动 Asset 文件夹
relative_link: false     #把链接改为与根目录的相对位址
future: true             #显示未来的文章
highlight:               #代码块的设置
  enable: true
  line_number: true
  auto_detect: false
  tab_replace:
  
# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10           
  order_by: -date
  
# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10    #每页显示的文章量 (0 = 关闭分页功能)
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next    #主题

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:       #部署部分的设置
  type: git
  repo: xxxxxxxxxx
  branch: master

hexo 命令

clean

清除缓存文件 (db.json) 和已生成的静态文件 (public)。
在某些情况(尤其是更换主题后),如果发现您对站点的更改无论如何也不生效,您可能需要运行该命令。

hexo clean

generate

生成静态文件。

hexo generate

server

启动服务器。默认情况下,访问网址为: http://localhost:4000/。

hexo server

写文章

hexo new [layout] post

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值