從零開始

2018-05-25 13:51 更新

2017年最新基于hexo搭建個(gè)人免費(fèi)博客——從零開始

前言

搭建此博客是因?yàn)橥ㄟ^github上了解到github pages進(jìn)而知道了可以把靜態(tài)網(wǎng)頁博客托管給github倉庫 或許您已經(jīng)通Git + Hexo 搭建個(gè)人博客網(wǎng)站了解到如何通過HEXO + GIT 實(shí)現(xiàn)個(gè)人博客網(wǎng)站的建立。但是盡管您已經(jīng)成功建立博客網(wǎng)站,但是你需要對(duì)網(wǎng)站做合適的配置和調(diào)整才能迎合你的網(wǎng)站要求。本文主要介紹HEXO的基本操作命令和網(wǎng)站的基本配置方法。

github pages介紹

Github Pages 是 github 公司提供的免費(fèi)的靜態(tài)網(wǎng)站托管服務(wù),用起來方便而且功能強(qiáng)大,不僅沒有空間限制(為免費(fèi)用戶提供了500M空間),還可以綁定自己的域名。 到 https://pages.github.com/ 上,看到可以創(chuàng)建的網(wǎng)站有兩類,一類是為自己或者是自己的組織創(chuàng)建站點(diǎn),就是新建一個(gè)倉庫,倉庫的名字叫做,username.github.io 或者是 orgnizationname.github.io ,注意這里的 usernameorgnizationname 要嚴(yán)格替換成你自己的用戶名或者組織名,大小寫也要區(qū)分,不然就會(huì)有問題。然后就往倉庫里面放頁面內(nèi)容就行了。第二類是為項(xiàng)目創(chuàng)建網(wǎng)站,這個(gè)其實(shí)主要步驟都是一樣的,只不過稍微比創(chuàng)建用戶或組織網(wǎng)站復(fù)雜一點(diǎn)點(diǎn)。 githubpages githubpages githubpages 具體的可以看這個(gè)網(wǎng)址的講解Github Pages

域名注冊(cè)和綁定

我是在萬網(wǎng)注冊(cè)的域名和設(shè)置DNS解析,所以我只會(huì)講在阿里云下的域名綁定。 域名注冊(cè)和綁定 進(jìn)入到控制臺(tái)后點(diǎn)擊自己剛買的域名進(jìn)入域名管理界面,域名注冊(cè)和綁定然后進(jìn)行添加解析操作,按照途中所給的值填寫,注意將記錄值改為自己的github pages地址域名注冊(cè)和綁定域名注冊(cè)和綁定 最后一步必須在所建立的github倉庫的主分支里建立一個(gè)CNAME文件內(nèi)容為你要解析到的目地地址關(guān)鍵一步 注意 這個(gè)CNAME文件要放到source文件里面我的路徑為

  1. D:\hexo\blog\source\

放到這個(gè)下面的用意為你每次hexo d的時(shí)候會(huì)把你原先倉庫的所有東西清除掉,所以你的CNAME文件也會(huì)沒有,這樣可以避免這種情況發(fā)生

hexo安裝和配置

Hexo博客搭建的基礎(chǔ)大致流程為: 安裝Node.js →安裝Git → 安裝Hexo → 安裝主題 → 本地測(cè)試運(yùn)行 → 注冊(cè)給github與coding并創(chuàng)建pages倉庫 → 部署 Node.js和git的安裝大家自己去網(wǎng)上搜下,當(dāng)以上都安好后可以通過git bash來輸入命令查看是否安裝成功以及對(duì)應(yīng)的版本

hexo安裝和配置

隨后執(zhí)行下述命令來安裝hexo

  1. npm install -g hexo-cli

hexo初始化

安裝完成后要先提前建好一個(gè)文件夾,所以我在自己D盤建立了一個(gè)hexo文件夾,里面隨后剪了一個(gè)blog文件夾,用命令cd到blog這個(gè)目錄

  1. cd d:/hexo/blog

執(zhí)行命令

  1. hexo init # hexo會(huì)在目標(biāo)文件夾建立網(wǎng)站所需要的所有文件
  2. npm install # 安裝依賴包

本地啟動(dòng)

有了必要的各種配置文件之后就可以在本地預(yù)覽效果了

  1. hexo g # 等同于hexo generate,生成靜態(tài)文件到public文件夾
  2. hexo s # 等同于hexo server,在本地服務(wù)器運(yùn)行

還有個(gè)命令

  1. hexo clean #作用為清除靜態(tài)文件夾的內(nèi)容并刪掉,主要用于更改變更了某些地方導(dǎo)致頁面顯示不完善

之后打開瀏覽器并輸入IP地址 http://localhost:4000/ 查看,效果如下 hexo安裝和配置

新建頁面和文章

  1. hexo new "title" # 生成新文章:\source\_posts\title.md
  2. hexo new page "title" # 生成新的頁面,后面可在主題配置文件中配置頁面

生成文章或頁面的模板放在博客文件夾根目錄下的 scaffolds/ 文件夾里面,文章對(duì)應(yīng)的是 post.md ,頁面對(duì)應(yīng)的是page.md,草稿的是draft.md

編輯文章

打開新建的文章\source_posts\postName.md,其中postName是hexo new "title"中的title

  1. ---
  2. title: Start My Blog Trip Power By Hexo # 文章頁面上的顯示名稱,可以任意修改,不會(huì)出現(xiàn)在URL
  3. date: 2017-2-10 23:49:28 # 文章生成時(shí)間,一般不改
  4. categories: diary # 文章分類目錄,多個(gè)分類使用[a,b,c]這種格式
  5. tags: [Hexo,diary] # 文章標(biāo)簽
  6. ---
  7. #這里開始使用markdown格式輸入你的正文。
  8. <!--more-->
  9. #more標(biāo)簽以下的內(nèi)容要點(diǎn)擊“閱讀全文”才能看見,#more標(biāo)簽以上的內(nèi)容為你首頁顯示文章的摘要部分

MD文章編輯

如果你對(duì)MD語法不熟悉,推薦你去馬克飛象使用它的在線網(wǎng)頁編輯,可以實(shí)現(xiàn)一邊打字一邊查看效果,很方便。 地址:https://maxiang.io/

常用命令總結(jié)

  1. hexo init [folder] # 初始化一個(gè)網(wǎng)站。如果沒有設(shè)置 folder ,Hexo 默認(rèn)在目前的文件夾建立網(wǎng)站
  2. hexo new [layout] <title> # 新建一篇文章。如果沒有設(shè)置 layout 的話,默認(rèn)使用 _config.yml 中的 default_layout 參數(shù)代替。如果標(biāo)題包含空格的話,請(qǐng)使用引號(hào)括起來
  3. hexo version # 查看版本
  4. hexo clean # 清除緩存文件 (db.json) 和已生成的靜態(tài)文件 (public)
  5. hexo g # 等于hexo generate # 生成靜態(tài)文件
  6. hexo s # 等于hexo server # 本地預(yù)覽
  7. hexo d # 等于hexo deploy # 部署,可與hexo g合并為 hexo d -g

安裝主題

前言

截止2017年,hexo和next都在更新,現(xiàn)今網(wǎng)上的版本和其對(duì)應(yīng)的配置文件都已經(jīng)發(fā)生了巨大的變化,所以我把官網(wǎng)最新的17年的版本配置文件的詳情給大家來講解,大家可以下最新的版本和看我的配置進(jìn)行修改。

主題下載

hexo主題有很多,這里我自己使用的next主題所以就以它來講。我的版本為v5.1.0(目前最新) 下載地址: https://github.com/iissnan/hexo-theme-next/releases 把下來的文件夾解壓和更名為next,并復(fù)制到theme目錄下主題下載

HEXO網(wǎng)站的配置文件

  1. 在根目錄下的_config.yml主要是對(duì)網(wǎng)站的總屬性進(jìn)行設(shè)置
  2. 如:網(wǎng)站標(biāo)題,網(wǎng)站logo,網(wǎng)站插件使用等全局的屬性
  3. 主題目錄下的_config.yml主要是針對(duì)網(wǎng)站的布局,導(dǎo)航等特性設(shè)置進(jìn)行設(shè)置

我的根目錄配置文件

  1. ## Hexo Configuration
  2. ## Docs: https://hexo.io/docs/configuration.html
  3. ## Source: https://github.com/hexojs/hexo/
  4. ## Site
  5. title: Water Sister's Blog
  6. subtitle: 生活、技術(shù)個(gè)人博客
  7. description: 思考中.....
  8. author: Yang ZiHao
  9. language: zh-Hans
  10. timezone:
  11. ## URL
  12. ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
  13. url: http://www.cduyzh.com
  14. root: /
  15. permalink: :title/
  16. permalink_defaults:
  17. ## Directory
  18. source_dir: source
  19. public_dir: public
  20. tag_dir: tags
  21. archive_dir: archives
  22. category_dir: categories
  23. code_dir: downloads/code
  24. i18n_dir: :lang
  25. skip_render:
  26. - baidu_verify_n9RJHacKra.html
  27. - google5caece7c800b9ce3.html
  28. ## Writing
  29. new_post_name: :title.md # File name of new posts
  30. default_layout: post
  31. titlecase: false # Transform title into titlecase
  32. external_link: true # Open external links in new tab
  33. filename_case: 0
  34. render_drafts: false
  35. post_asset_folder: true
  36. relative_link: false
  37. future: true
  38. highlight:
  39. enable: true
  40. line_number: true
  41. auto_detect: false
  42. tab_replace:
  43. ## Category & Tag
  44. default_category: uncategorized
  45. category_map:
  46. tag_map:
  47. ## Date / Time format
  48. ## Hexo uses Moment.js to parse and display date
  49. ## You can customize the date format as defined in
  50. ## http://momentjs.com/docs/#/displaying/format/
  51. date_format: YYYY-MM-DD
  52. time_format: HH:mm:ss
  53. ## Pagination
  54. ## Set per_page to 0 to disable pagination
  55. per_page: 10
  56. pagination_dir: page
  57. ## Extensions
  58. Plugins:
  59. - hexo-generator-sitemap
  60. - hexo-generator-baidu-sitemap
  61. ## Plugins: https://hexo.io/plugins/
  62. ## Themes: https://hexo.io/themes/
  63. theme: next
  64. ## Deployment
  65. ## Docs: https://hexo.io/docs/deployment.html
  66. deploy:
  67. type: git
  68. repo:
  69. github: git@github.com:cduyzh/cduyzh.github.io.git,master
  70. index_generator:
  71. per_page: 5
  72. archive_generator:
  73. per_page: 20
  74. yearly: true
  75. monthly: true
  76. tag_generator:
  77. per_page: 10
  78. menu:
  79. about: /about
  80. #頭像設(shè)置
  81. avatar: /images/yzh.jpg
  82. ## 多說熱評(píng)文章 true 或者 false
  83. duoshuo_hotartical: true
  84. #sitemap
  85. ## hexo sitemap
  86. sitemap:
  87. path: sitemap.xml
  88. baidusitemap:
  89. path: baidusitemap.xml
  90. #local search
  91. search:
  92. path: search.xml
  93. field: post
  94. format: html
  95. limit: 1000

我的主題目錄配置文件

  1. ## ---------------------------------------------------------------
  2. ## Site Information Settings
  3. ## ---------------------------------------------------------------
  4. ## Put your favicon.ico into `hexo-site/source/` directory.
  5. favicon: /images/favicon.ico
  6. ## Set default keywords (Use a comma to separate)
  7. keywords: "cduyzh前端開發(fā)博客"
  8. ## Set rss to false to disable feed link.
  9. ## Leave rss as empty to use site's feed link.
  10. ## Set rss to specific value if you have burned your feed already.
  11. rss:
  12. ## Specify the date when the site was setup
  13. #since: 2015
  14. ## icon between year and author @Footer
  15. authoricon: tint
  16. ## Footer `powered-by` and `theme-info` copyright
  17. copyright: false
  18. ## Canonical, set a canonical link tag in your hexo, you could use it for your SEO of blog.
  19. ## See: https://support.google.com/webmasters/answer/139066
  20. ## Tips: Before you open this tag, remember set up your URL in hexo _config.yml ( ex. url: http://yourdomain.com )
  21. canonical: true
  22. ## Change headers hierarchy on site-subtitle (will be main site description) and on all post/pages titles for better SEO-optimization.
  23. seo: true
  24. ## ---------------------------------------------------------------
  25. ## Menu Settings
  26. ## ---------------------------------------------------------------
  27. ## When running the site in a subdirectory (e.g. domain.tld/blog), remove the leading slash (/archives -> archives)
  28. menu:
  29. home: /
  30. categories: /categories
  31. about: /about
  32. archives: /archives
  33. tags: /tags
  34. #commonweal: /404.html
  35. #sitemap: /sitemap.xml
  36. life: /categories/life
  37. technology: //categories/technology
  38. ## Enable/Disable menu icons.
  39. ## Icon Mapping:
  40. ## Map a menu item to a specific FontAwesome icon name.
  41. ## Key is the name of menu item and value is the name of FontAwesome icon. Key is case-senstive.
  42. ## When an question mask icon presenting up means that the item has no mapping icon.
  43. menu_icons:
  44. enable: true
  45. #KeyMapsToMenuItemKey: NameOfTheIconFromFontAwesome
  46. home: home
  47. about: user
  48. categories: th
  49. schedule: calendar
  50. tags: tags
  51. archives: archive
  52. sitemap: sitemap
  53. commonweal: heart
  54. life: coffee
  55. technology: cog
  56. ## ---------------------------------------------------------------
  57. ## Scheme Settings
  58. ## ---------------------------------------------------------------
  59. ## Schemes
  60. #scheme: Muse
  61. scheme: Mist
  62. #scheme: Pisces
  63. ## ---------------------------------------------------------------
  64. ## Font Settings
  65. ## - Find fonts on Google Fonts (https://www.google.com/fonts)
  66. ## - All fonts set here will have the following styles:
  67. ## light, light italic, normal, normal italic, bold, bold italic
  68. ## - Be aware that setting too much fonts will cause site running slowly
  69. ## - Introduce in 5.0.1
  70. ## ---------------------------------------------------------------
  71. font:
  72. enable: true
  73. # Uri of fonts host. E.g. //fonts.googleapis.com (Default)
  74. host:
  75. # Global font settings used on <body> element.
  76. global:
  77. # external: true will load this font family from host.
  78. external: true
  79. family: Lato
  80. # Font settings for Headlines (h1, h2, h3, h4, h5, h6)
  81. # Fallback to `global` font settings.
  82. headings:
  83. external: true
  84. family:
  85. # Font settings for posts
  86. # Fallback to `global` font settings.
  87. posts:
  88. external: true
  89. family:
  90. # Font settings for Logo
  91. # Fallback to `global` font settings.
  92. # The `size` option use `px` as unit
  93. logo:
  94. external: true
  95. family:
  96. size:
  97. # Font settings for <code> and code blocks.
  98. codes:
  99. external: true
  100. family:
  101. size:
  102. ## ---------------------------------------------------------------
  103. ## Sidebar Settings
  104. ## ---------------------------------------------------------------
  105. ## Social Links
  106. ## Key is the link label showing to end users.
  107. ## Value is the target link (E.g. GitHub: https://github.com/iissnan)
  108. social:
  109. #LinkLabel: Link
  110. GitHub: https://github.com/cduyzh
  111. 知乎: https://www.zhihu.com/people/yang-zi-hao-cheng-du-da-xue
  112. Weibo: http://weibo.com/3290722423/
  113. QQ: http://wpa.qq.com/msgrd?v=3&uin=450311265&site=qq&menu=yes
  114. ## Social Links Icons
  115. ## Icon Mapping:
  116. ## Map a menu item to a specific FontAwesome icon name.
  117. ## Key is the name of the item and value is the name of FontAwesome icon. Key is case-senstive.
  118. ## When an globe mask icon presenting up means that the item has no mapping icon.
  119. social_icons:
  120. enable: true
  121. # Icon Mappings.
  122. # KeyMapsToSocialItemKey: NameOfTheIconFromFontAwesome
  123. GitHub: github
  124. #Twitter: twitter
  125. Weibo: weibo
  126. QQ: qq
  127. ## Sidebar Avatar
  128. ## in theme directory(source/images): /images/avatar.jpg
  129. ## in site directory(source/uploads): /uploads/avatar.jpg
  130. #avatar:
  131. ## Table Of Contents in the Sidebar
  132. toc:
  133. enable: true
  134. # Automatically add list number to toc.
  135. number: true
  136. ## Creative Commons 4.0 International License.
  137. ## http://creativecommons.org/
  138. ## Available: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero
  139. #creative_commons: by-nc-sa
  140. #creative_commons:
  141. sidebar:
  142. # Sidebar Position, available value: left | right
  143. position: left
  144. #position: right
  145. # Sidebar Display, available value:
  146. # - post expand on posts automatically. Default.
  147. # - always expand for all pages automatically
  148. # - hide expand only when click on the sidebar toggle icon.
  149. # - remove Totally remove sidebar including sidebar toggle.
  150. #display: post
  151. display: always
  152. #display: hide
  153. #display: remove
  154. # Sidebar offset from top menubar in pixels.
  155. offset: 12
  156. offset_float: 0
  157. # Back to top in sidebar
  158. b2t: false
  159. # Scroll percent label in b2t button
  160. scrollpercent: false
  161. ## Blog rolls
  162. links_title: Links
  163. #links_layout: block
  164. #links_layout: inline
  165. links:
  166. hexo: https://hexo.io/zh-cn/
  167. next: http://theme-next.iissnan.com/
  168. web project: http://www.watersister.top
  169. ## ---------------------------------------------------------------
  170. ## Post Settings
  171. ## ---------------------------------------------------------------
  172. ## Automatically scroll page to section which is under <!-- more --> mark.
  173. scroll_to_more: true
  174. ## Automatically excerpt description in homepage as preamble text.
  175. excerpt_description: true
  176. ## Automatically Excerpt. Not recommend.
  177. ## Please use <!-- more --> in the post to control excerpt accurately.
  178. auto_excerpt:
  179. enable: true
  180. length: 400
  181. ## Post meta display settings
  182. post_meta:
  183. item_text: true
  184. created_at: true
  185. updated_at: false
  186. categories: true
  187. ## Post wordcount display settings
  188. ## Dependencies: https://github.com/willin/hexo-wordcount
  189. post_wordcount:
  190. item_text: true
  191. wordcount: true
  192. min2read: true
  193. #Wechat Subscriber
  194. #wechat_subscriber:
  195. ## enabled: true
  196. ## qcode: /images/wechatpay.jpg
  197. ## description: subscribe to my blog by scanning my public wechat account
  198. ## ---------------------------------------------------------------
  199. ## Misc Theme Settings
  200. ## ---------------------------------------------------------------
  201. ## Custom Logo.
  202. ## !!Only available for Default Scheme currently.
  203. ## Options:
  204. ## enabled: [true/false] - Replace with specific image
  205. ## image: url-of-image - Images's url
  206. custom_logo:
  207. enabled: false
  208. image:
  209. ## Code Highlight theme
  210. ## Available value:
  211. ## normal | night | night eighties | night blue | night bright
  212. ## https://github.com/chriskempson/tomorrow-theme
  213. highlight_theme: night
  214. ## ---------------------------------------------------------------
  215. ## Third Party Services Settings
  216. ## ---------------------------------------------------------------
  217. ## MathJax Support
  218. mathjax:
  219. enable: false
  220. per_page: false
  221. cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
  222. ## Swiftype Search API Key
  223. #swiftype_key:
  224. ## Baidu Analytics ID
  225. #baidu_analytics:
  226. ## Duoshuo ShortName
  227. duoshuo_shortname: cduyzh
  228. ## Disqus
  229. #disqus_shortname:
  230. ## Hypercomments
  231. #hypercomments_id:
  232. ## Gentie productKey
  233. #gentie_productKey:
  234. ## Support for youyan comments system.
  235. ## You can get your uid from http://www.uyan.cc
  236. #youyan_uid: your uid
  237. ## Support for LiveRe comments system.
  238. ## You can get your uid from https://livere.com/insight/myCode (General web site)
  239. #livere_uid: your uid
  240. ## Baidu Share
  241. ## Available value:
  242. ## button | slide
  243. ## Warning: Baidu Share does not support https.
  244. #baidushare:
  245. ## type: button
  246. ## Share
  247. #jiathis:
  248. ## Warning: JiaThis does not support https.
  249. #add_this_id:
  250. ## Share
  251. duoshuo_share: true
  252. ## Google Webmaster tools verification setting
  253. ## See: https://www.google.com/webmasters/
  254. #google_site_verification:
  255. ## Google Analytics
  256. #google_analytics:
  257. ## Yandex Webmaster tools verification setting
  258. ## See: https://webmaster.yandex.ru/
  259. #yandex_site_verification:
  260. ## CNZZ count
  261. #cnzz_siteid:
  262. ## Application Insights
  263. ## See https://azure.microsoft.com/en-us/services/application-insights/
  264. ## application_insights:
  265. ## Make duoshuo show UA
  266. ## user_id must NOT be null when admin_enable is true!
  267. ## you can visit http://dev.duoshuo.com get duoshuo user id.
  268. duoshuo_info:
  269. ua_enable: true
  270. admin_enable: false
  271. user_id: 6224774254659896065
  272. admin_nickname: author
  273. ## Facebook SDK Support.
  274. ## https://github.com/iissnan/hexo-theme-next/pull/410
  275. facebook_sdk:
  276. enable: false
  277. app_id: #<app_id>
  278. fb_admin: #<user_id>
  279. like_button: #true
  280. webmaster: #true
  281. ## Facebook comments plugin
  282. ## This plugin depends on Facebook SDK.
  283. ## If facebook_sdk.enable is false, Facebook comments plugin is unavailable.
  284. facebook_comments_plugin:
  285. enable: false
  286. num_of_posts: 10 # min posts num is 1
  287. width: 100% # default width is 550px
  288. scheme: light # default scheme is light (light or dark)
  289. ## VKontakte API Support.
  290. ## To get your AppID visit https://vk.com/editapp?act=create
  291. vkontakte_api:
  292. enable: false
  293. app_id: #<app_id>
  294. like: true
  295. comments: true
  296. num_of_posts: 10
  297. ## Show number of visitors to each article.
  298. ## You can visit https://leancloud.cn get AppID and AppKey.
  299. leancloud_visitors:
  300. enable: true
  301. app_id: TxBSdzFliqxOpec29xEd8pO5-gzGzoHsz
  302. app_key: 5rH911Nhs9V7AWFjEYqe8Bz7
  303. ## Show PV/UV of the website/page with busuanzi.
  304. ## Get more information on http://ibruce.info/2015/04/04/busuanzi/
  305. busuanzi_count:
  306. # count values only if the other configs are false
  307. enable: true
  308. # custom uv span for the whole site
  309. site_uv: true
  310. site_uv_header: <i class="fa fa-user"></i> 訪問用戶:
  311. site_uv_footer:
  312. # custom pv span for the whole site
  313. site_pv: true
  314. site_pv_header: <i class="fa fa-eye"></i> 訪問次數(shù):
  315. site_pv_footer:
  316. # custom pv span for one page only
  317. page_pv: false
  318. page_pv_header: <i class="fa fa-file-o"></i> 點(diǎn)擊量
  319. page_pv_footer:
  320. ## Tencent analytics ID
  321. ## tencent_analytics:
  322. ## Tencent MTA ID
  323. ## tencent_mta:
  324. ## Enable baidu push so that the blog will push the url to baidu automatically which is very helpful for SEO
  325. baidu_push: true
  326. ## Google Calendar
  327. ## Share your recent schedule to others via calendar page
  328. ## ## API Documentation:
  329. ## https://developers.google.com/google-apps/calendar/v3/reference/events/list
  330. calendar:
  331. enable: false
  332. calendar_id: <required>
  333. api_key: <required>
  334. orderBy: startTime
  335. offsetMax: 24
  336. offsetMin: 4
  337. timeZone:
  338. showDeleted: false
  339. singleEvents: true
  340. maxResults: 250
  341. ## Algolia Search
  342. algolia_search:
  343. enable: false
  344. hits:
  345. per_page: 10
  346. labels:
  347. input_placeholder: Search for Posts
  348. hits_empty: "We didn't find any results for the search: ${query}"
  349. hits_stats: "${hits} results found in ${time} ms"
  350. ## Local search
  351. local_search:
  352. enable: true
  353. ## External URL with BASE64 encrypt & decrypt
  354. ## Usage: {% exturl text url "title" %}
  355. ## Alias: {% extlink text url "title" %}
  356. exturl: false
  357. #! ---------------------------------------------------------------
  358. #! DO NOT EDIT THE FOLLOWING SETTINGS
  359. #! UNLESS YOU KNOW WHAT YOU ARE DOING
  360. #! ---------------------------------------------------------------
  361. ## Motion
  362. use_motion: true
  363. ## Fancybox
  364. fancybox: true
  365. ## Canvas-nest
  366. canvas_nest: true
  367. ## Script Vendors.
  368. ## Set a CDN address for the vendor you want to customize.
  369. ## For example
  370. ## jquery: https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
  371. ## Be aware that you should use the same version as internal ones to avoid potential problems.
  372. ## Please use the https protocol of CDN files when you enable https on your site.
  373. vendors:
  374. # Internal path prefix. Please do not edit it.
  375. _internal: lib
  376. # Internal version: 2.1.3
  377. jquery: //cdn.bootcss.com/jquery/2.1.3/jquery.min.js
  378. # Internal version: 2.1.5
  379. # Fancybox: http://fancyapps.com/fancybox/
  380. fancybox: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.pack.js
  381. fancybox_css: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css
  382. # Internal version: 1.0.6
  383. fastclick: //cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js
  384. # Internal version: 1.9.7
  385. # See: https://github.com/tuupola/jquery_lazyload
  386. lazyload: //cdn.bootcss.com/jquery_lazyload/1.9.7/jquery.lazyload.min.js
  387. # Internal version: 1.2.1
  388. velocity:
  389. # Internal version: 1.2.1
  390. velocity_ui:
  391. # Internal version: 0.7.9
  392. # See: https://faisalman.github.io/ua-parser-js/
  393. ua_parser:
  394. # Internal version: 4.6.2
  395. # See: http://fontawesome.io/
  396. fontawesome: //cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css
  397. # Internal version: 1
  398. # https://www.algolia.com
  399. algolia_instant_js:
  400. algolia_instant_css:
  401. # Internal version: 1.0.0
  402. # https://github.com/hustcc/canvas-nest.js
  403. canvas_nest: //cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js
  404. ## Assets
  405. css: css
  406. js: js
  407. images: images
  408. ## Theme version
  409. version: 5.1.0
  410. ## 多說熱評(píng)文章 true 或者 false
  411. duoshuo_hotartical: true
  412. reward_comment: 堅(jiān)持原創(chuàng)技術(shù)分享,您的支持將鼓勵(lì)我繼續(xù)創(chuàng)作!
  413. wechatpay: /images/wechatpay.jpg
  414. alipay: /images/alipay.jpg

PS:可以不用一次性看完,理解下各個(gè)屬性即可,官網(wǎng)也沒有對(duì)所有配置的中文解釋,只有一些例子配置對(duì)應(yīng)的參數(shù)而已。

相信絕大數(shù)人都沒看完,大家可以后面自己配置的時(shí)候再來看。

啟用主題

打開站點(diǎn)配置文件, 找到 theme 字段,并將其值更改為 next

  1. theme: next

注意:后有個(gè)空格必須要有空格哦 然后 hexo s 即可在localshost:4000地址里預(yù)覽主題效果

更換主題外觀

next有三個(gè)主題樣式

  1. ## Schemes
  2. #scheme: Muse
  3. scheme: Mist
  4. #scheme: Pisces

我用的是第二個(gè)

更換語言為中文,在根目錄配置文件下配置language: zh-Hans

  1. ## Site
  2. title: Water Sister's Blog
  3. subtitle: 生活、技術(shù)個(gè)人博客
  4. description: 思考中.....
  5. author: Yang ZiHao
  6. language: zh-Hans
  7. timezone:

添加網(wǎng)站小圖標(biāo)

在主題目錄配置文件下設(shè)置

  1. ## Put your favicon.ico into `hexo-site/source/` directory.
  2. favicon: /images/favicon.ico

大部分的設(shè)定都能在NexT的官方文檔 里面找到,如側(cè)欄、頭像、打賞、評(píng)論、訂閱、連接、分享、數(shù)據(jù)統(tǒng)計(jì)等等,在此就不多講了,照著文檔走就行了,接下只是個(gè)性定制的問題。 所以給個(gè)官方文檔大家可以自己去看一遍: http://theme-next.iissnan.com/theme-settings.html

部署發(fā)行項(xiàng)目

前言

假設(shè)前面已經(jīng)注冊(cè)了github帳號(hào)和創(chuàng)建了對(duì)應(yīng)的倉庫,通過配置SSH來建立連接。

生成SSH

  1. $ ssh-keygen -t rsa -C "郵件地址@youremail.com"
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):<回車>

系統(tǒng)會(huì)要求你輸入密碼,這里設(shè)置的密碼主要是在你提交Git時(shí)彈出密碼認(rèn)證,不想輸入直接回車

  1. Enter passphrase (empty for no passphrase):<輸入加密串>
  2. Enter same passphrase again:<再次輸入加密串>

成功后如圖: 生成SSH

配置SSH

找到id_rsa.pub 并復(fù)制文件內(nèi)容 id_rsa.pub文件一般位于電腦用戶配置文件夾下的一個(gè).ssh文件下C:\Users\你的用戶名.ssh 登錄Github并添加密鑰 進(jìn)入github首頁在右上角選擇settings設(shè)置。 生成SSH 創(chuàng)建一個(gè)新的SSH key,圖中顯示我已經(jīng)創(chuàng)建好了。 title可以隨便取 生成SSH

測(cè)試通過git bash鏈接到Git

鏈接Git

  1. $ ssh -T git@github.com

提示如下:yes

  1. The authenticity of host 'github.com (207.65.227.44)' can't be established.
  2. RSA key fingerprint is 16:27:42:18:60:1d:7b:13:d2:b5:c4:20:7e:56:86:d8:71:f3
  3. Are you sure you want to continue connecting (yes/no)?

以下為成功鏈接到Git

  1. Hi XXXX! You've successfully authenticated, but GitHub does not provide shell access.

使用Git bash簡單的設(shè)置一下用戶信息:

  1. git config --global user.name your name
  2. git config --global user.email your_email@youremail.com

部署到Github

在此之前,先安裝Git部署插件

  1. npm install hexo-deployer-git --save

打開根目錄配置文件,拉到底部,修改部署配置:

  1. deploy:
  2. type: git
  3. repo:
  4. github: git@github.com:cduyzh/cduyzh.github.io.git,master

注意冒號(hào)后面是網(wǎng)站對(duì)應(yīng)的用戶名,接著就是/,然后再是你的項(xiàng)目名加上 .git,master

保存后終端執(zhí)行

  1. hexo clean
  2. hexo g
  3. hexo d

結(jié)果如下為成功上傳 部署到Github

總結(jié)

到這里基本上完成了hexo的配置和項(xiàng)目的上傳,后面我會(huì)講一些文章的編輯,分類,標(biāo)簽的運(yùn)用,還會(huì)對(duì)next主題進(jìn)行一些分析,如果想自己設(shè)置主題和樣式建議先把next主題的官方中文文檔看一下,我會(huì)對(duì)其中的一些進(jìn)行解釋。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)