Linux搭建hexo博客【centos7.3+node.js+git+hexo】

299 阅读2分钟

一、安装node.js 1、下载 #wget nodejs.org/dist/v9.3.0… 2、解压 #xz -d node-v9.3.0-linux-x64.tar.xz #tar -xvf node-v9.3.0-linux-x64.tar 3、移动 #mv node-v9.3.0-linux-x64 /usr/local/node 4、配环境变量 #vim /etc/profile export PATH=$PATH:/usr/local/node/bin #source /etc/profile 5、设置软连接 #ln -s /soft/hexo/nodejs/bin/node /usr/local/bin/node #ln -s /soft/hexo/nodejs/bin/npm /usr/local/bin/npm

二、安装git #yum install git -y

三、安装hexo 1、安装hexo #mkdir hexo #cd hexo #npm install -g hexo-cli #npm安装hexo #hexo init #初始化 #这里可以测试下效果 #hexo s 登录成功进行下面的步骤 2、安装插件 #npm install hexo-generator-index --save #npm install hexo-generator-archive --save #npm install hexo-generator-category --save #npm install hexo-generator-tag --save #npm install hexo-server --save #npm install hexo-deployer-git --save #npm install hexo-deployer-heroku --save #npm install hexo-deployer-rsync --save #npm install hexo-deployer-openshift --save #npm install hexo-renderer-marked --save #npm install hexo-renderer-stylus --save #npm install hexo-generator-feed --save #npm install hexo-generator-sitemap --save 3、改hexo主配置文件_config.yml #Hexo Configuration ##Docs: hexo.io/docs/config… ##Source: github.com/hexojs/hexo…

#Site 站点信息设置 title: #站名 subtitle: #副标题 description: #站描述 author: #作者 keywords:#关键词 language: zh-CN #语言 timezone:

#URL 链接设置 ##If your site is put in a subdirectory, set url as 'yoursite.com/child' and root as '/child/' curl: http://你的访问地址 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 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 auto_detect: 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 ##momentjs.com/docs/#/disp… date_format: YYYY-MM-DD time_format: HH:mm:ss

#Pagination 分页 ##Set per_page to 0 to disable pagination per_page: 5 pagination_dir: page

#Extensions 扩展 ##Plugins: hexo.io/plugins/ ##Themes: hexo.io/themes/ theme: #博客主题名,可以hexo官网更换

#Deployment 这里设置了Git获 #这里一定要注意不要写错了,否则部署到Github上会出问题 ##Docs: hexo.io/docs/deploy… deploy: type: git repo: git@github.com:四大点五小点创建的项目,一般都是用户名加项目名 #也可以这样 repo: github.com/用户名/项目名 branch: master message: '站点更新:{{now("YYYY-MM-DD HH/mm/ss")}}'

#yilia主题加的配置
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 1、浏览器注册github账号 2、登录github #git config --global user.email "you@example.com" #git config --global user.name "Your Name" 3、生成ssh秘钥 #ssh-keygen -t rsa -C example@126.com #less ~/.ssh/id_rsa.pub 4、把生成的秘钥添加到github中 5、github上自己创建项目也可以clone别人的项目 6、上传代码到github #hexo g && hexo d

五、可以访问你的博客了 #hexo s