如何拥有个人的Github技术博客

article/2025/10/29 0:42:06

0?wx_fmt=png

题图:87testing.com


前不久用wordpress搭建了一个博客,用起来感觉不是太好用,并且数据库经常会发生异常挂掉,没找到解决方案。


看到有不少人使用的hexo+github方式搭建属于自己的博客,

于是,我也做了一些尝试,将搭建的过程整理出来,希望也能帮到他人。


同时,推荐没有Blog的朋友也尝试自己搭建下,中间可能会遇到一些问题,解决问题的过程很痛苦,但是只要爱折腾,最终都能迎刃而解。


一、环境准备


1、安装git (https://git-scm.com/downloads) 安装目的:用来把本地的hexo内容push到github上。

2、安装node(https://nodejs.org/en/download/)安装目的:用来生成静态页面

3、申请github账号(https://github.com/) ssh keys相关的配置之前介绍过,这里就不过多描述:http://www.87testing.com/2017/07/02/pycharm-e5-85-b3-e8-81-94github/



二、安装hexo


1、创建一个文件夹blog,进入到这个blog目录,安装hexo,执行:sudo npm install -g hexo


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ sudo npm install -g hexo

Password:

npm WARN deprecated swig@1.4.2: This package is no longer maintained

/usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo/bin/hexo


> dtrace-provider@0.8.5 install /usr/local/lib/node_modules/hexo/node_modules/dtrace-provider

> node scripts/install.js



> fsevents@1.1.2 install /usr/local/lib/node_modules/hexo/node_modules/fsevents

> node install


[fsevents] Success: "/usr/local/lib/node_modules/hexo/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed

Pass --update-binary to reinstall or --build-from-source to recompile


> hexo-util@0.6.1 postinstall /usr/local/lib/node_modules/hexo/node_modules/hexo-util

> npm run build:highlight



> hexo-util@0.6.1 build:highlight /usr/local/lib/node_modules/hexo/node_modules/hexo-util

> node scripts/build_highlight_alias.js > highlight_alias.json


/usr/local/lib

└─┬ hexo@3.3.8 

  ├── abbrev@1.1.0 

  ├── archy@1.0.0 

  ├── bluebird@3.5.0 

  ├─┬ chalk@1.1.3 

  │ ├── ansi-styles@2.2.1 

  │ ├── escape-string-regexp@1.0.5 

  │ ├─┬ has-ansi@2.0.0 

  │ │ └── ansi-regex@2.1.1 

  │ ├── strip-ansi@3.0.1 

  │ └── supports-color@2.0.0 

  ├─┬ cheerio@0.20.0 

  │ ├─┬ css-select@1.2.0 

  │ │ ├── boolbase@1.0.0 

  │ │ ├── css-what@2.1.0 

  │ │ ├── domutils@1.5.1 

  │ │ └── nth-check@1.0.1 

  │ ├─┬ dom-serializer@0.1.0 

  │ │ └── domelementtype@1.1.3 

  │ ├── entities@1.1.1 

  │ ├─┬ htmlparser2@3.8.3 

  │ │ ├── domelementtype@1.3.0 

  │ │ ├── domhandler@2.3.0 

  │ │ ├── entities@1.0.0 

  │ │ └─┬ readable-stream@1.1.14 

  │ │   ├── core-util-is@1.0.2 

  │ │   ├── isarray@0.0.1 

  │ │   └── string_decoder@0.10.31 

  │ └─┬ jsdom@7.2.2 

  │   ├── abab@1.0.3 

  │   ├── acorn@2.7.0 

  │   ├── acorn-globals@1.0.9 

  │   ├── cssom@0.3.2 

  │   ├── cssstyle@0.2.37 

  │   ├─┬ escodegen@1.8.1 

  │   │ ├── esprima@2.7.3 

  │   │ ├── estraverse@1.9.3 

  │   │ ├── esutils@2.0.2 

  │   │ ├─┬ optionator@0.8.2 

  │   │ │ ├── deep-is@0.1.3 

  │   │ │ ├── fast-levenshtein@2.0.6 

  │   │ │ ├── levn@0.3.0 

  │   │ │ ├── prelude-ls@1.1.2 

  │   │ │ ├── type-check@0.3.2 

  │   │ │ └── wordwrap@1.0.0 

  │   │ └── source-map@0.2.0 

  │   ├── nwmatcher@1.4.1 

  │   ├── parse5@1.5.1 

  │   ├─┬ request@2.81.0 

  │   │ ├── aws-sign2@0.6.0 

  │   │ ├── aws4@1.6.0 

  │   │ ├── caseless@0.12.0 

  │   │ ├─┬ combined-stream@1.0.5 

  │   │ │ └── delayed-stream@1.0.0 

  │   │ ├── extend@3.0.1 

  │   │ ├── forever-agent@0.6.1 

  │   │ ├─┬ form-data@2.1.4 

  │   │ │ └── asynckit@0.4.0 

  │   │ ├─┬ har-validator@4.2.1 

  │   │ │ ├─┬ ajv@4.11.8 

  │   │ │ │ ├── co@4.6.0 

  │   │ │ │ └─┬ json-stable-stringify@1.0.1 

  │   │ │ │   └── jsonify@0.0.0 

  │   │ │ └── har-schema@1.0.5 

  │   │ ├─┬ hawk@3.1.3 

  │   │ │ ├── boom@2.10.1 

  │   │ │ ├── cryptiles@2.0.5 

  │   │ │ ├── hoek@2.16.3 

  │   │ │ └── sntp@1.0.9 

  │   │ ├─┬ http-signature@1.1.1 

  │   │ │ ├── assert-plus@0.2.0 

  │   │ │ ├─┬ jsprim@1.4.1 

  │   │ │ │ ├── assert-plus@1.0.0 

  │   │ │ │ ├── extsprintf@1.3.0 

  │   │ │ │ ├── json-schema@0.2.3 

  │   │ │ │ └─┬ verror@1.10.0 

  │   │ │ │   └── assert-plus@1.0.0 

  │   │ │ └─┬ sshpk@1.13.1 

  │   │ │   ├── asn1@0.2.3 

  │   │ │   ├── assert-plus@1.0.0 

  │   │ │   ├── bcrypt-pbkdf@1.0.1 

  │   │ │   ├─┬ dashdash@1.14.1 

  │   │ │   │ └── assert-plus@1.0.0 

  │   │ │   ├── ecc-jsbn@0.1.1 

  │   │ │   ├─┬ getpass@0.1.7 

  │   │ │   │ └── assert-plus@1.0.0 

  │   │ │   ├── jsbn@0.1.1 

  │   │ │   └── tweetnacl@0.14.5 

  │   │ ├── is-typedarray@1.0.0 

  │   │ ├── isstream@0.1.2 

  │   │ ├── json-stringify-safe@5.0.1 

  │   │ ├─┬ mime-types@2.1.16 

  │   │ │ └── mime-db@1.29.0 

  │   │ ├── oauth-sign@0.8.2 

  │   │ ├── performance-now@0.2.0 

  │   │ ├── qs@6.4.0 

  │   │ ├── safe-buffer@5.1.1 

  │   │ ├── stringstream@0.0.5 

  │   │ ├── tunnel-agent@0.6.0 

  │   │ └── uuid@3.1.0 

  │   ├── sax@1.2.4 

  │   ├── symbol-tree@3.2.2 

  │   ├─┬ tough-cookie@2.3.2 

  │   │ └── punycode@1.4.1 

  │   ├── webidl-conversions@2.0.1 

  │   ├─┬ whatwg-url-compat@0.6.5 

  │   │ └── tr46@0.0.3 

  │   └── xml-name-validator@2.0.1 

  ├─┬ deep-assign@2.0.0 

  │ └── is-obj@1.0.1 

  ├─┬ hexo-cli@1.0.3 

  │ ├── command-exists@1.2.2 

  │ ├── minimist@1.2.0 

  │ └── object-assign@4.1.1 

  ├── hexo-front-matter@0.2.3 

  ├─┬ hexo-fs@0.2.1 

  │ ├─┬ chokidar@1.7.0 

  │ │ ├─┬ anymatch@1.3.2 

  │ │ │ ├─┬ micromatch@2.3.11 

  │ │ │ │ ├─┬ arr-diff@2.0.0 

  │ │ │ │ │ └── arr-flatten@1.1.0 

  │ │ │ │ ├── array-unique@0.2.1 

  │ │ │ │ ├─┬ braces@1.8.5 

  │ │ │ │ │ ├─┬ expand-range@1.8.2 

  │ │ │ │ │ │ └─┬ fill-range@2.2.3 

  │ │ │ │ │ │   ├── is-number@2.1.0 

  │ │ │ │ │ │   ├─┬ isobject@2.1.0 

  │ │ │ │ │ │   │ └── isarray@1.0.0 

  │ │ │ │ │ │   ├─┬ randomatic@1.1.7 

  │ │ │ │ │ │   │ ├─┬ is-number@3.0.0 

  │ │ │ │ │ │   │ │ └── kind-of@3.2.2 

  │ │ │ │ │ │   │ └── kind-of@4.0.0 

  │ │ │ │ │ │   └── repeat-string@1.6.1 

  │ │ │ │ │ ├── preserve@0.2.0 

  │ │ │ │ │ └── repeat-element@1.1.2 

  │ │ │ │ ├─┬ expand-brackets@0.1.5 

  │ │ │ │ │ └── is-posix-bracket@0.1.1 

  │ │ │ │ ├── extglob@0.3.2 

  │ │ │ │ ├── filename-regex@2.0.1 

  │ │ │ │ ├─┬ kind-of@3.2.2 

  │ │ │ │ │ └── is-buffer@1.1.5 

  │ │ │ │ ├─┬ object.omit@2.0.1 

  │ │ │ │ │ ├─┬ for-own@0.1.5 

  │ │ │ │ │ │ └── for-in@1.0.2 

  │ │ │ │ │ └── is-extendable@0.1.1 

  │ │ │ │ ├─┬ parse-glob@3.0.4 

  │ │ │ │ │ ├── glob-base@0.3.0 

  │ │ │ │ │ └── is-dotfile@1.0.3 

  │ │ │ │ └─┬ regex-cache@0.4.3 

  │ │ │ │   ├── is-equal-shallow@0.1.3 

  │ │ │ │   └── is-primitive@2.0.0 

  │ │ │ └─┬ normalize-path@2.1.1 

  │ │ │   └── remove-trailing-separator@1.0.2 

  │ │ ├── async-each@1.0.1 

  │ │ ├─┬ fsevents@1.1.2 

  │ │ │ ├── nan@2.6.2 

  │ │ │ └─┬ node-pre-gyp@0.6.36 

  │ │ │   ├─┬ mkdirp@0.5.1 

  │ │ │   │ └── minimist@0.0.8 

  │ │ │   ├─┬ nopt@4.0.1 

  │ │ │   │ ├── abbrev@1.1.0 

  │ │ │   │ └─┬ osenv@0.1.4 

  │ │ │   │   ├── os-homedir@1.0.2 

  │ │ │   │   └── os-tmpdir@1.0.2 

  │ │ │   ├─┬ npmlog@4.1.0 

  │ │ │   │ ├─┬ are-we-there-yet@1.1.4 

  │ │ │   │ │ └── delegates@1.0.0 

  │ │ │   │ ├── console-control-strings@1.1.0 

  │ │ │   │ ├─┬ gauge@2.7.4 

  │ │ │   │ │ ├── aproba@1.1.1 

  │ │ │   │ │ ├── has-unicode@2.0.1 

  │ │ │   │ │ ├── object-assign@4.1.1 

  │ │ │   │ │ ├── signal-exit@3.0.2 

  │ │ │   │ │ ├─┬ string-width@1.0.2 

  │ │ │   │ │ │ ├── code-point-at@1.1.0 

  │ │ │   │ │ │ └─┬ is-fullwidth-code-point@1.0.0 

  │ │ │   │ │ │   └── number-is-nan@1.0.1 

  │ │ │   │ │ ├─┬ strip-ansi@3.0.1 

  │ │ │   │ │ │ └── ansi-regex@2.1.1 

  │ │ │   │ │ └── wide-align@1.1.2 

  │ │ │   │ └── set-blocking@2.0.0 

  │ │ │   ├─┬ rc@1.2.1 

  │ │ │   │ ├── deep-extend@0.4.2 

  │ │ │   │ ├── ini@1.3.4 

  │ │ │   │ ├── minimist@1.2.0 

  │ │ │   │ └── strip-json-comments@2.0.1 

  │ │ │   ├─┬ request@2.81.0 

  │ │ │   │ ├── aws-sign2@0.6.0 

  │ │ │   │ ├── aws4@1.6.0 

  │ │ │   │ ├── caseless@0.12.0 

  │ │ │   │ ├─┬ combined-stream@1.0.5 

  │ │ │   │ │ └── delayed-stream@1.0.0 

  │ │ │   │ ├── extend@3.0.1 

  │ │ │   │ ├── forever-agent@0.6.1 

  │ │ │   │ ├─┬ form-data@2.1.4 

  │ │ │   │ │ └── asynckit@0.4.0 

  │ │ │   │ ├─┬ har-validator@4.2.1 

  │ │ │   │ │ ├─┬ ajv@4.11.8 

  │ │ │   │ │ │ ├── co@4.6.0 

  │ │ │   │ │ │ └─┬ json-stable-stringify@1.0.1 

  │ │ │   │ │ │   └── jsonify@0.0.0 

  │ │ │   │ │ └── har-schema@1.0.5 

  │ │ │   │ ├─┬ hawk@3.1.3 

  │ │ │   │ │ ├── boom@2.10.1 

  │ │ │   │ │ ├── cryptiles@2.0.5 

  │ │ │   │ │ ├── hoek@2.16.3 

  │ │ │   │ │ └── sntp@1.0.9 

  │ │ │   │ ├─┬ http-signature@1.1.1 

  │ │ │   │ │ ├── assert-plus@0.2.0 

  │ │ │   │ │ ├─┬ jsprim@1.4.0 

  │ │ │   │ │ │ ├── assert-plus@1.0.0 

  │ │ │   │ │ │ ├── extsprintf@1.0.2 

  │ │ │   │ │ │ ├── json-schema@0.2.3 

  │ │ │   │ │ │ └── verror@1.3.6 

  │ │ │   │ │ └─┬ sshpk@1.13.0 

  │ │ │   │ │   ├── asn1@0.2.3 

  │ │ │   │ │   ├── assert-plus@1.0.0 

  │ │ │   │ │   ├── bcrypt-pbkdf@1.0.1 

  │ │ │   │ │   ├─┬ dashdash@1.14.1 

  │ │ │   │ │   │ └── assert-plus@1.0.0 

  │ │ │   │ │   ├── ecc-jsbn@0.1.1 

  │ │ │   │ │   ├─┬ getpass@0.1.7 

  │ │ │   │ │   │ └── assert-plus@1.0.0 

  │ │ │   │ │   ├── jodid25519@1.0.2 

  │ │ │   │ │   ├── jsbn@0.1.1 

  │ │ │   │ │   └── tweetnacl@0.14.5 

  │ │ │   │ ├── is-typedarray@1.0.0 

  │ │ │   │ ├── isstream@0.1.2 

  │ │ │   │ ├── json-stringify-safe@5.0.1 

  │ │ │   │ ├─┬ mime-types@2.1.15 

  │ │ │   │ │ └── mime-db@1.27.0 

  │ │ │   │ ├── oauth-sign@0.8.2 

  │ │ │   │ ├── performance-now@0.2.0 

  │ │ │   │ ├── qs@6.4.0 

  │ │ │   │ ├── safe-buffer@5.0.1 

  │ │ │   │ ├── stringstream@0.0.5 

  │ │ │   │ ├─┬ tough-cookie@2.3.2 

  │ │ │   │ │ └── punycode@1.4.1 

  │ │ │   │ ├── tunnel-agent@0.6.0 

  │ │ │   │ └── uuid@3.0.1 

  │ │ │   ├─┬ rimraf@2.6.1 

  │ │ │   │ └─┬ glob@7.1.2 

  │ │ │   │   ├── fs.realpath@1.0.0 

  │ │ │   │   ├── inflight@1.0.6 

  │ │ │   │   ├─┬ minimatch@3.0.4 

  │ │ │   │   │ └─┬ brace-expansion@1.1.7 

  │ │ │   │   │   ├── balanced-match@0.4.2 

  │ │ │   │   │   └── concat-map@0.0.1 

  │ │ │   │   └── path-is-absolute@1.0.1 

  │ │ │   ├── semver@5.3.0 

  │ │ │   ├─┬ tar@2.2.1 

  │ │ │   │ ├── block-stream@0.0.9 

  │ │ │   │ ├─┬ fstream@1.0.11 

  │ │ │   │ │ └── graceful-fs@4.1.11 

  │ │ │   │ └── inherits@2.0.3 

  │ │ │   └─┬ tar-pack@3.4.0 

  │ │ │     ├─┬ debug@2.6.8 

  │ │ │     │ └── ms@2.0.0 

  │ │ │     ├── fstream-ignore@1.0.5 

  │ │ │     ├─┬ once@1.4.0 

  │ │ │     │ └── wrappy@1.0.2 

  │ │ │     ├─┬ readable-stream@2.2.9 

  │ │ │     │ ├── buffer-shims@1.0.0 

  │ │ │     │ ├── core-util-is@1.0.2 

  │ │ │     │ ├── isarray@1.0.0 

  │ │ │     │ ├── process-nextick-args@1.0.7 

  │ │ │     │ ├── string_decoder@1.0.1 

  │ │ │     │ └── util-deprecate@1.0.2 

  │ │ │     └── uid-number@0.0.6 

  │ │ ├── glob-parent@2.0.0 

  │ │ ├── inherits@2.0.3 

  │ │ ├─┬ is-binary-path@1.0.1 

  │ │ │ └── binary-extensions@1.9.0 

  │ │ ├─┬ is-glob@2.0.1 

  │ │ │ └── is-extglob@1.0.0 

  │ │ ├── path-is-absolute@1.0.1 

  │ │ └─┬ readdirp@2.1.0 

  │ │   ├─┬ readable-stream@2.3.3 

  │ │   │ ├── isarray@1.0.0 

  │ │   │ ├── process-nextick-args@1.0.7 

  │ │   │ ├── string_decoder@1.0.3 

  │ │   │ └── util-deprecate@1.0.2 

  │ │   └── set-immediate-shim@1.0.1 

  │ └── graceful-fs@4.1.11 

  ├─┬ hexo-i18n@0.2.1 

  │ └── sprintf-js@1.0.3 

  ├─┬ hexo-log@0.1.3 

  │ └─┬ bunyan@1.8.12 

  │   ├── dtrace-provider@0.8.5 

  │   ├─┬ mv@2.1.1 

  │   │ ├─┬ mkdirp@0.5.1 

  │   │ │ └── minimist@0.0.8 

  │   │ ├── ncp@2.0.0 

  │   │ └─┬ rimraf@2.4.5 

  │   │   └─┬ glob@6.0.4 

  │   │     ├─┬ inflight@1.0.6 

  │   │     │ └── wrappy@1.0.2 

  │   │     └── once@1.4.0 

  │   └── safe-json-stringify@1.0.4 

  ├─┬ hexo-util@0.6.1 

  │ ├─┬ camel-case@3.0.0 

  │ │ ├─┬ no-case@2.3.1 

  │ │ │ └── lower-case@1.1.4 

  │ │ └── upper-case@1.1.3 

  │ ├─┬ cross-spawn@4.0.2 

  │ │ ├─┬ lru-cache@4.1.1 

  │ │ │ ├── pseudomap@1.0.2 

  │ │ │ └── yallist@2.1.2 

  │ │ └─┬ which@1.3.0 

  │ │   └── isexe@2.0.0 

  │ ├── highlight.js@9.12.0 

  │ ├── html-entities@1.2.1 

  │ └── striptags@2.2.1 

  ├─┬ js-yaml@3.9.1 

  │ ├── argparse@1.0.9 

  │ └── esprima@4.0.0 

  ├── lodash@4.17.4 

  ├─┬ minimatch@3.0.4 

  │ └─┬ brace-expansion@1.1.8 

  │   ├── balanced-match@1.0.0 

  │   └── concat-map@0.0.1 

  ├── moment@2.13.0 

  ├── moment-timezone@0.5.13 

  ├─┬ nunjucks@2.5.2 

  │ ├── asap@2.0.6 

  │ └─┬ yargs@3.32.0 

  │   ├── camelcase@2.1.1 

  │   ├─┬ cliui@3.2.0 

  │   │ └── wrap-ansi@2.1.0 

  │   ├── decamelize@1.2.0 

  │   ├─┬ os-locale@1.4.0 

  │   │ └─┬ lcid@1.0.0 

  │   │   └── invert-kv@1.0.0 

  │   ├─┬ string-width@1.0.2 

  │   │ ├── code-point-at@1.1.0 

  │   │ └─┬ is-fullwidth-code-point@1.0.0 

  │   │   └── number-is-nan@1.0.1 

  │   ├── window-size@0.1.4 

  │   └── y18n@3.2.1 

  ├── pretty-hrtime@1.0.3 

  ├─┬ strip-indent@1.0.1 

  │ └── get-stdin@4.0.1 

  ├─┬ swig@1.4.2 

  │ ├─┬ optimist@0.6.1 

  │ │ ├── minimist@0.0.10 

  │ │ └── wordwrap@0.0.3 

  │ └─┬ uglify-js@2.4.24 

  │   ├── async@0.2.10 

  │   ├─┬ source-map@0.1.34 

  │   │ └── amdefine@1.0.1 

  │   ├── uglify-to-browserify@1.0.2 

  │   └─┬ yargs@3.5.4 

  │     ├── camelcase@1.2.1 

  │     ├── window-size@0.1.0 

  │     └── wordwrap@0.0.2 

  ├─┬ swig-extras@0.0.1 

  │ └─┬ markdown@0.5.0 

  │   └── nopt@2.1.2 

  ├── text-table@0.2.0 

  ├─┬ tildify@1.2.0 

  │ └── os-homedir@1.0.2 

  ├── titlecase@1.1.2 

  └─┬ warehouse@2.2.0 

    ├─┬ cuid@1.3.8 

    │ ├── browser-fingerprint@0.0.1 

    │ ├── core-js@1.2.7 

    │ └── node-fingerprint@0.0.2 

    ├─┬ is-plain-object@2.0.4 

    │ └── isobject@3.0.1 

    └─┬ JSONStream@1.3.1 

      ├── jsonparse@1.3.1 

      └── through@2.3.8 



2、初始化hexo,执行:hexo init


此时,blog目录就是博客的根目录,已经建立完成了。


3、生成静态页面,执行:hexo g(或者执行:hexo generate)


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ hexo g

INFO  Start processing

INFO  Files loaded in 408 ms

INFO  Generated: index.html

INFO  Generated: archives/index.html

INFO  Generated: fancybox/blank.gif

INFO  Generated: fancybox/jquery.fancybox.css

INFO  Generated: fancybox/jquery.fancybox.js

INFO  Generated: fancybox/jquery.fancybox.pack.js

INFO  Generated: fancybox/fancybox_loading.gif

INFO  Generated: fancybox/fancybox_loading@2x.gif

INFO  Generated: fancybox/fancybox_overlay.png

INFO  Generated: fancybox/fancybox_sprite.png

INFO  Generated: fancybox/fancybox_sprite@2x.png

INFO  Generated: archives/2017/08/index.html

INFO  Generated: archives/2017/index.html

INFO  Generated: css/fonts/FontAwesome.otf

INFO  Generated: js/script.js

INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.css

INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.js

INFO  Generated: fancybox/helpers/jquery.fancybox-media.js

INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.css

INFO  Generated: css/style.css

INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.js

INFO  Generated: css/fonts/fontawesome-webfont.eot

INFO  Generated: css/fonts/fontawesome-webfont.woff

INFO  Generated: fancybox/helpers/fancybox_buttons.png

INFO  Generated: css/images/banner.jpg

INFO  Generated: css/fonts/fontawesome-webfont.svg

INFO  Generated: css/fonts/fontawesome-webfont.ttf

INFO  Generated: 2017/08/10/hello-world/index.html

INFO  28 files generated in 1.41 s


4、本地启动hexo,执行:hexo server


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ hexo server

INFO  Start processing

INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.


浏览器输入http://localhost:4000,即可打开hexo博客页面:如图:

0?wx_fmt=png



此时只是完成了本地启动hexo,将本地的blog push到github上还需要本地跟github建立连接,接下来对github进行配置。



三、github配置


1、github上创建代码仓库


建立Repository,仓库名:yourname.github.io


2、然后再本地blog目录的_config.yml配置文件中最后一行增加如下配置:


deploy:

  type: git

  repo: https://github.com/TTtesting/tttesting.github.io.git

  branch: master

冒号后面记得加空格,不然会报错。


3、_congig.yml配置修改保存后,执行如下命令:

npm install hexo-deployer-git --save


如下代表执行成功:

TTZhangdeMacBook-Pro:blog admin$ npm install hexo-deployer-git --save

hexo-site@0.0.0 /Users/admin/software/blog

└─┬ hexo-deployer-git@0.3.1 

  ├─┬ babel-eslint@7.2.3 

  │ ├─┬ babel-code-frame@6.22.0 

  │ │ └── js-tokens@3.0.2 

  │ ├─┬ babel-traverse@6.25.0 

  │ │ ├── babel-messages@6.23.0 

  │ │ ├─┬ babel-runtime@6.25.0 

  │ │ │ ├── core-js@2.5.0 

  │ │ │ └── regenerator-runtime@0.10.5 

  │ │ ├── debug@2.6.8 

  │ │ ├── globals@9.18.0 

  │ │ └─┬ invariant@2.2.2 

  │ │   └── loose-envify@1.3.1 

  │ ├─┬ babel-types@6.25.0 

  │ │ └── to-fast-properties@1.0.3 

  │ └── babylon@6.17.4 

  └── moment@2.18.1 


4、执行配置命令:

TTZhangdeMacBook-Pro:blog admin$ hexo deploy

INFO  Deploying: git

INFO  Setting up Git deployment...

Initialized empty Git repository in /Users/admin/software/blog/.deploy_git/.git/

[master (root-commit) d37715b] First commit

 1 file changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 placeholder

INFO  Clearing .deploy_git folder...

INFO  Copying files from public folder...

INFO  Copying files from extend dirs...

[master 28f7f04] Site updated: 2017-08-10 21:52:38

 29 files changed, 5758 insertions(+)

 create mode 100644 2017/08/10/hello-world/index.html

 create mode 100644 archives/2017/08/index.html

 create mode 100644 archives/2017/index.html

 create mode 100644 archives/index.html

 create mode 100644 css/fonts/FontAwesome.otf

 create mode 100644 css/fonts/fontawesome-webfont.eot

 create mode 100644 css/fonts/fontawesome-webfont.svg

 create mode 100644 css/fonts/fontawesome-webfont.ttf

 create mode 100644 css/fonts/fontawesome-webfont.woff

 create mode 100644 css/images/banner.jpg

 create mode 100644 css/style.css

 create mode 100644 fancybox/blank.gif

 create mode 100644 fancybox/fancybox_loading.gif

 create mode 100644 fancybox/fancybox_loading@2x.gif

 create mode 100644 fancybox/fancybox_overlay.png

 create mode 100644 fancybox/fancybox_sprite.png

 create mode 100644 fancybox/fancybox_sprite@2x.png

 create mode 100644 fancybox/helpers/fancybox_buttons.png

 create mode 100644 fancybox/helpers/jquery.fancybox-buttons.css

 create mode 100644 fancybox/helpers/jquery.fancybox-buttons.js

 create mode 100644 fancybox/helpers/jquery.fancybox-media.js

 create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.css

 create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.js

 create mode 100644 fancybox/jquery.fancybox.css

 create mode 100644 fancybox/jquery.fancybox.js

 create mode 100644 fancybox/jquery.fancybox.pack.js

 create mode 100644 index.html

 create mode 100644 js/script.js

 delete mode 100644 placeholder

To https://github.com/TTtesting/tttesting.github.io.git

 * [new branch]      HEAD -> master

Branch master set up to track remote branch master from https://github.com/TTtesting/tttesting.github.io.git.

INFO  Deploy done: git


此时本地与gitbub仓库已建立连接,浏览器中输入:https://tttesting.github.io,即可打开blog ,如图:

0?wx_fmt=png



四、更新本地修改到github


本地修改后每次部署的步骤,可按以下三步来进行。


    hexo clean


    hexo generate


    hexo deploy


一些常用命令:


hexo new"postName" #新建文章


hexo new page"pageName" #新建页面


hexo generate #生成静态页面至public目录


hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)


hexo deploy #将.deploy目录部署到GitHub


hexo help # 查看帮助


hexo version #查看Hexo的版本



五、博客首页显示所有文章列表配置


1、请确保node版本大于6.2

2、在博客根目录执行命令:npm i hexo-generator-json-content --save

3、在根目录_config.yml里添加配置:

  jsonContent:

    meta: false

    pages: false

    posts:

      title: true

      date: true

      path: true

      text: false

      raw: false

      content: false

      slug: false

      updated: false

      comments: false

      link: false

      permalink: false

      excerpt: false

      categories: false

      tags: true



最后,


给大家呈现出我的博客地址,如果只要借助github,就可使用github域名:https://tttesting.github.io


同时,有服务器的可以部署在自己的服务器上,使用自己申请的域名,欢迎访问我的博客:http://www.87testing.com


请加入测试技术分享圈,开始您的学习之旅吧!



长按二维码 一键加入  640?wx_fmt=jpeg

87testing.com

长按识别二维码加入:测试技术分享圈

640?wx_fmt=png




http://chatgpt.dhexx.cn/article/dMpEnub0.shtml

相关文章

github博客+hexo

这里基于ubuntu18,win10其实一样的,把sudo去掉就行了 安装 安装git 配置github的ssh 安装Node.js 版本需不低于 10.13,建议使用 Node.js 12.0 及以上版本 建议换个源 npm install express --registryhttps://registry.npm.taobao.org在gi…

【hexo+gitee/github】博客搭建

文章目录 参考资料1. 使用gitee(github)与hexo好处2. 安装2.1 安装Nodejs2.2 安装git2.3 安装Hexo 3. 建站4. 启动5. 配置5.1 主题配置 6. 部署到gitee pages6.1 创建一个gitee仓库6.2 配置路径6.3 开启GiteePages服务6.4 github pages部署6.4. 博客源代…

hexo+github部署个人博客

文章目录 hexogithub部署个人博客前期准备hexo搭建个人博客新建GitHub仓库将个人博客部署到Git pages写文章和发布文章Hexo优化修改博客目录下的_config.yml配置 matery主题美化 hexogithub部署个人博客 前期准备 安装git git的下载地址安装node.js node.js注册github账号&am…

利用github进行自定义博客地址

写在前面: 大家好,我是 花狗Fdog ,来自内蒙古的一个小城市,目前在泰州读书。 很感谢能有这样一个平台让我能够在这里分享所学所感。 我喜欢编程,喜欢代码,喜欢去做一个程序员。 努力学习,争取多…

如何搭建github.io博客

零、宣传我的Github.io博客 https://ruixiangjiang.github.io/ 如果我的电脑没开就不能访问。。。正在调试中。。。 一、注册一个账号 进入www.github.com ,然后注册。首页右上角头像那里有一个“”号,点击后选择“New repositor”。创建完之后点击“…

使用Github.io打造个人博客网站

Github.io上可以方便地打造自己的博客网站,相对于CSDN等社区网站来说既没有广告又能凸显个人调性。 建站步骤 建站步骤非常简单 在个人github上建一个repository,名字必须是username.github.io 推送一个静态html上去 # clone the prj git clone htt…

搭建hexo+Github博客

摘要 本文主要向大家介绍了如何搭建hexo-Github博客的详细过程,有需要的朋友们可以尝试阅读,希望对大家有帮助。 简要吐槽 搭博客其实没那么麻烦,但是在网上各类教程的“指导下”,我不知道放弃了多少次又重新试了多少次&#xff…

GitHub: 个人博客搭建

GitHub: 个人博客搭建 食材:jekyll 工具:GitHub,visual studio code,chrome。 第一步:安装Jekyll,具体参考官方链接 https://www.jekyll.com.cn/docs/step-by-step/01-setup/ 操作指南 安装一个完整的…

hexo+github搭建博客(超级详细版,精细入微)

转载此文章前,请先联系作者,经作者同意后再转载,并请注明原文链接和作者,整理这些不容易,最终版权归作者所有,谢谢合作!移步我的个人博客:https://yafine-blog.cn,阅读体…

用github搭建个人(博客网站

🌈博客主页:卿云阁 💌欢迎关注🎉点赞👍收藏⭐️留言📝 🌟本文由卿云阁原创! 🙏作者水平很有限,如果发现错误,请留言轰炸哦!万分感谢&a…

个人博客构建——github个人博客

摘要 为什么需要构建自己的博客呢?第一,是为解决平台的可能随意删除自己博文,需要有一个不被其他所左右的分享平台,第二,需要一个载体来记录的自己的学习内容,第三,也是为自己自媒体提前做一个…

Hexo+GitHub免费搭建个人博客(保姆级教程)

文章目录 HexoGitHub免费搭建个人博客(保姆级教程)安装依赖环境Git的下载与安装Node.js下载与安装:red_circle:***注意一***:red_circle:***注意二*** Git和Node.js工具工作状态检验:red_circle:**注意三** 安装Hexo:ng:小插曲1:ng:小插曲3: 生成博客文件博客效果预…

教程:纯小白如何搭建自己的Github博客并写第一篇博文

文章目录 1 搭建Github博客1.1 确认github上创建的repository名称1.2 用系统命令行安装hexo并初始化本地博客文件夹1.3 下载并安装hexo NexT主题1.4 更新部署博客页面 2 创建并发布自己的第一篇文章2.1 用hexo new命令创建文章脚本2.2 编辑文章2.3 发布文章/更新博客 写在前面&…

搭建自己的github.io博客

搭建自己的github.io博客 github.io是基于github的repo管理,这意味着咱们对其是有觉得的控制,这个跟放在第三方的平台比,可控性要好太多。下面咱们将详细讲述如何基于github.io打造属于自己的博客网站。 要完成自己的github.io博客网站&…

github个人博客快速搭建教程

文章目录 首先搭建起一个github博客1 左上角标题及简介以及下方的介绍2 评论和访客数3 文章4 Home Archives Categories 和 Tags5 Collections6 Demo7 About 首先搭建起一个github博客 首先建立一个个人博客github仓库。其实只要把 需要的代码 fork下来, 仓库名改为自己的{{gi…

如何使用Github搭建个人博客

介绍 在本文中,我将介绍如何使用GitHub搭建个人博客(免费)。GitHub是一个功能强大的版本控制和协作平台,它也可以用来托管和发布静态网页。通过将你的个人博客托管在GitHub上,你可以享受到版本控制的好处,…

github完成个人博客的搭建过程

依托于github完成个人博客的搭建过程,但目前只完成了基础部分 Todo: {% cb 评论功能,false, false %} {% cb 版权信息,false, false %} {% cb 页面个性化,false, false %} {% cb 云服务器部署,false, false %}  阿里云学生免费领取6个月 {% cb 公网IP访问,false, f…

php书写规范

一、基本约定 1、源文件 &#xff08;1&#xff09;纯PHP代码源文件只使用 <?php 标签&#xff0c;省略关闭标签 ?> &#xff1b; &#xff08;2&#xff09;源文件中PHP代码的编码格式必须是无BOM的UTF-8格式&#xff1b; &#xff08;3&#xff09;使用 Unix LF(换…

SQL书写规范

SQL书写规范可以参考&#xff1a; SQL样式指南 SQL style guide by Simon Holywell

实验报告怎么写之书写规范

实验报告怎么写之书写规范 前几天交深度学习实验报告&#xff0c;由于写得太随意被助教师姐给批了… 之前一直觉得写报告是件特别烦人的事&#xff0c;随便写写就完事了&#xff0c;而且之前课程的实验对报告规范也都无要求&#xff0c;所以我就养成了随便写报告的习惯。但是…