Jacman基于Pacman修改的Hexo主題

title: Jacman基于Pacman修改的Hexo主題
date: 2018-04-19 17:11:20
categories: Hexo
description: Jacman是一款基于Pacman修改并堅持更新的Hexo主題


前言

Pacman是一款為Hexo打造的一款扁平化,有著響應式設計的主題。 由于Pacman已經暫停更新,加上Hexo已經升級為3.0,很多主題需要重新適配,而Jacman是基于Pacman修改而來,在前端設計樣式和功能上做了很多合理的修改和完善,相信你也一定可以很快上手。

Jacman是一款基于Pacman修改并堅持更新的Hexo主題


更新歷史

2018年04月19日 - 更新Hexo自動部署至GitLab方案
2015年12月30日 - 更新Jacman配置參數
2015年11月29日 - 更新Jacman配置細節
2015年03月22日 - 初稿

閱讀原文 - https://wsgzao.github.io/post/hexo-pacman/

擴展閱讀


主題安裝

設置很簡單,請參考原文中文說明

Jacman

http://wuchong.me/blog/2014/11/20/how-to-use-jacman/


配置yml

這是我自己的真實配置文件,請參考原文注釋做修改

全局yml

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

# Site
title: HelloDog
subtitle: Keep Calm and Carry On
description: HelloDog是一個基于Github和Hexo的靜態Blog,希望用簡單而清晰的寫作方式Markdown分享自己的心得體會。
author: wsgzao
language: zh-CN
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://wsgzao.github.io # with the https protocol
enforce_ssl: wsgzao.github.io # without any protocol
root: /
permalink: post/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :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
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  tab_replace:

# 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
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: jacman

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type:

# Others
index_generator:
  per_page: 5 ##首頁默認10篇文章標題 如果值為0不分頁

archive_generator:
    per_page: 0 ##歸檔頁面默認10篇文章標題
    yearly: true  ##生成年視圖
    monthly: true ##生成月視圖

tag_generator:
    per_page: 0 ##標簽分類頁面默認10篇文章

category_generator: 
    per_page: 0 ###分類頁面默認10篇文章

feed:
    type: atom ##feed類型 atom或者rss2
    path: atom.xml ##feed路徑
    limit: 20  ##feed文章最小數量


主題yml

##### Menu
menu:
  主頁 | Home: /
  索引 | Index: /index/
  歸檔 | Archives: /archives/
  簡介 | About: /about/
## you can create `tags` and `categories` folders in `../source`.
## And create a `index.md` file in each of them.
## set `front-matter`as
## layout: tags (or categories)
## title: tags (or categories)
## ---

#### Widgets
widgets: 
- github-card
- category
- links
- rss
  ## provide eight widgets:github-card,category,tag,rss,archive,tagcloud,links,weibo

#### RSS 
rss: /atom.xml ## RSS address.

#### Image
imglogo:
  enable: true             ## display image logo true/false.
  src: img/logo.png        ## `.svg` and `.png` are recommended,please put image into the theme folder `/jacman/source/img`.
favicon: img/favicon.ico   ## size:32px*32px,`.ico` is recommended,please put image into the theme folder `/jacman/source/img`.     
apple_icon: img/jacman.jpg ## size:114px*114px,please put image into the theme folder `/jacman/source/img`.
author_img: img/author.jpg ## size:220px*220px.display author avatar picture.if don't want to display,please don't set this.
banner_img: #img/banner.jpg ## size:1920px*200px+. Banner Picture
### Theme Color 
theme_color:
    theme: '#ea6753'    ##the defaut theme color is blue

# 代碼高亮主題
# available: default | night
highlight_theme: night

#### index post is expanding or not 
index:
  expand: false           ## default is unexpanding,so you can only see the short description of each post.
  excerpt_link: Read More  

close_aside: true  #close sidebar in post page if true
mathjax: false      #enable mathjax if true

### Creative Commons License Support, see http://creativecommons.org/ 
### you can choose: by , by-nc , by-nc-nd , by-nc-sa , by-nd , by-sa , zero
creative_commons: none

#### Author information
author:
  intro_line1:  "Hello, I'm OX. This is my blog on GitHub."    ## your introduction on the bottom of the page
  intro_line2:  "Keep Calm and Carry On."  ## the 2nd line
  weibo:  ## e.g. wuchong1014 or 2176287895 for http://weibo.com/2176287895
  weibo_verifier:  ## e.g. b3593ceb Your weibo-show widget verifier ,if you use weibo-show it is needed.
  tsina:      ## e.g. 2176287895  Your weibo ID,It will be used in share button.
  douban:     ## e.g. wuchong1014 or your id for https://www.douban.com/people/wuchong1014
  zhihu:      ## e.g. jark  for http://www.zhihu.com/people/jark
  email:      ## e.g. imjark@gmail.com
  twitter:    ## e.g. jarkwu for https://twitter.com/jarkwu
  github: wsgzao    ## e.g. wuchong for https://github.com/wuchong
  facebook:   ## e.g. imjark for https://facebook.com/imjark
  linkedin: aowang  ## e.g. wuchong1014 for https://www.linkedin.com/in/wuchong1014
  google_plus:    ## e.g. "111190881341800841449" for https://plus.google.com/u/0/111190881341800841449, the "" is needed!
  stackoverflow:  ## e.g. 3222790 for http://stackoverflow.com/users/3222790/jark
## if you set them, the corresponding  share button will show on the footer

#### Toc
toc:
  article: true   ## show contents in article.
  aside: true     ## show contents in aside.
## you can set both of the value to true of neither of them.
## if you don't want display contents in a specified post,you can modify `front-matter` and add `toc: false`.

#### Links
links:
  Jark's Blog: http://wuchong.me
  LinkedIn: https://www.linkedin.com/in/aowang

#### Comment
duoshuo_shortname:    ## e.g. wuchong   your duoshuo short name.
disqus_shortname: wsgzao    ## e.g. wuchong   your disqus short name.
gentie_key:           ## your 163 gentie key, see https://gentie.163.com/
changyan_appid:       ## changyan app id, see http://changyan.kuaizhan.com/
changyan_appkey:      ## changyan app key, see http://changyan.kuaizhan.com/
xianliao_appid: 12835       ## xianliao app key, see https://www.xianliao.me/

#### Share button
jiathis:
  enable: false ## if you use jiathis as your share tool,the built-in share tool won't be display.
  id: 1503875   ## e.g. 1889330 your jiathis ID. 
  tsina: 1913082125 ## e.g. 2176287895 Your weibo id,It will be used in share button.

#### Analytics
google_analytics:
  enable: true
  id: UA-77732745-1       ## e.g. UA-46321946-2 your google analytics ID.
  site: wsgzao.github.io     ## e.g. wuchong.me your google analytics site or set the value as auto.
## You MUST upgrade to Universal Analytics first!
## https://developers.google.com/analytics/devguides/collection/upgrade/?hl=zh_CN
baidu_tongji:
  enable: true
  sitecode: c2c5fc7d844d0973d9f77abd87f49c3c ## e.g. e6d1f421bbc9962127a50488f9ed37d1 your baidu tongji site code
cnzz_tongji:
  enable: false
  siteid:    ## e.g. 1253575964 your cnzz tongji site id

#### Miscellaneous
ShowCustomFont: true  ## you can change custom font in `variable.styl` and `font.styl` which in the theme folder `/jacman/source/css`.
fancybox: true        ## if you use gallery post or want use fancybox please set the value to true.
totop: true           ## if you want to scroll to top in every post set the value to true

#### Custom Search
google_cse: 
  enable: false
  cx:   ## e.g. 018294693190868310296:abnhpuysycw your Custom Search ID.
## https://www.google.com/cse/ 
## To enable the custom search You must create a "search" folder in '/source' and a "index.md" file
## set the 'front-matter' as
## layout: search 
## title: search
## ---
baidu_search:     ## http://zn.baidu.com/
  enable: false
  id: "3783770861532079376"  ## e.g. "783281470518440642"  for your baidu search id
  site: http://zhannei.baidu.com/cse/search  ## your can change to your site instead of the default site
  
swiftype:     ## https://swiftype.com/
  enable: true


內容發布

修改post預設格式

建議按照個人習慣修改hexo\scaffolds中的post.md

title: {{ title }}
date: {{ date }}
categories:
description:

生成文章

文章如含有有中文請修改編碼為UTF-8避免亂碼

1.命令生成初始文章,文件名空格會自動加-hyphen中橫線

hexo n "hexo post"

2.在hexo\source\_posts中編輯生成出來的hexo-post文件

title: hexo post #可以改成中文的,如“新文章”
date: 2015-01-14 21:31:42 #發表日期,可自定義修改排序
categories: blog #文章文類
tags: [博客,文章] #文章標簽,可以加入多標簽
---
#這里是正文,用Markdown書寫

3.本地預覽文章內容,登錄localhost:4000查看效果

hexo s

4.發布內容到public文件夾,然后我選擇手動復制同步到GitHub

hexo clean
hexo g

導航欄添加自定義頁面

1.命令手動生成自定義頁面

hexo n page "about"

2.編輯hexo/source/about/index.md內容
3.修改themes/jacman/_config.yml文件

menu:
  關于: /about

其它修改

RSS和sitemap

1.安裝RSS和sitemap插件

npm install hexo-generator-feed@1 --save
npm install hexo-generator-sitemap@1 --save

2.開啟RSS和sitemap功能,編輯hexo/_config.yml

feed:
  type: atom       #feed 類型 (atom/rss2)
  path: atom.xml   #rss 路徑
  limit: 20        #在 rss 中最多生成的文章數(0顯示所有)

3.修改thems/jacman/_config.yml,編輯Widgets和rss

#### Widgets
widgets:
- rss

rss: /atom.xml

4.手動提交生成出來的atom.xml文件給搜索引擎

添加404頁面

在GitHub根目錄下如wsgzao.github.io設置404.html即可,建議使用騰訊公益404

<html>
<head>
<meta charset="UTF-8" />
<title>404 | HelloDog</title>                                                                                              
</head>
<body>
<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8"></script>
</body>
</html>

網站統計

Jacman自帶的選擇足夠了

站內搜索

swiftype - https://swiftype.com/

利用swiftype為hexo添加站內搜索v2.0
http://www.jerryfu.net/post/search-engine-for-hexo-with-swiftype-v2.html

常見錯誤

  1. 修改配置文件時注意YAML語法,參數冒號:后一定要留空格
  2. 中文亂碼請修改文件編碼格式為UTF-8
  3. GitHub同步慢或者失敗請使用代理加速

Hexo 自動部署至 GitLab

網上很多已經有很多方法了,常見的可能有2種思路,當然也有人選擇容器或者Bitcron

  1. 基于hexo deploy 一鍵部署
  2. 基于Travis CI自動部署Hexo到GitHub

我想滿足的需求和大家一樣越簡單越好,只是我更多時候在本地編輯通過Evernote和Dropbox同步數據,發送至wsgzao.github.io的GitHub Page中,其實仔細思考一下用最純粹的命令不就好了。

以 Windows 10 環境 PowerShell 為例,在 Git Shell 家目錄創建 deploy_hexo.ps1

# hexo g
cd .\hexo
hexo clean
hexo g

# del old files
cd ..\wsgzao.github.io
Remove-Item about,archives,categories,css,fancybox,font,img,index,js,page,post -recurse -force

# deploy github
Copy-Item ..\hexo\public\* .\ -recurse -force
git add *
git commit -m "mod"
git push

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容