自定义个人微博排版

以个人博客为例,博客地址

准备工作

安装

$ npm install -g hexo-cli

初始化

$ hexo init <folder>
$ cd <folder>
$ npm install

创建新文章

$ hexo new "My New Post"

运行开发环境

$ hexo server
$ hexo s

构建

$ hexo generate
$ hexo g

部署

$ hexo deploy
$ hexo d

详细准备工作,可以查阅hexo官网

安装主题cactus,一个很程序员的主题,推荐!

克隆仓库,并且将源文件复制到博客项目中themes目录下

git clone https://github.com/probberechts/hexo-theme-cactus.git themes/cactus

themes/cactus/_config.yml相关配置,详细解释可以看官方文档

# 首页Projects的url
projects_url: https://github.com/xiaobinwu
# 设置页面方向
direction: ltr
# 首页导航
# $ hexo new page about,可以创建page页面
nav:
  home: /
  about: /about/
  articles: /archives/
  categories: /categories/
  search: /search/
# 社交链接
social_links:
  github: https://github.com/xiaobinwu
  mail: mailto:xiaobin_wu@yahoo.com
# 开启标签快捷方式
tags_overview: true
# 首页 Writing的展示条数
posts_overview:
  show_all_posts: false
  post_count: 5
  sort_updated: false
# 排列方式
archive:
  sort_updated: false
post:
  show_updated: false
# logo设置
logo:
  enabled: true
  width: 50
  height: 50
  url: /images/logo.png
  gravatar: false
# ico设置
favicon:
  desktop:
    url: /images/favicon.ico
    gravatar: false
  android:
    url: /images/favicon-192x192.png
    gravatar: false
  apple:
    url: /images/apple-touch-icon.png
    gravatar: false
# 高亮语法
highlight: kimbie.dark
# 博客主题色,dark, light, classic, white
colorscheme: dark
page_width: 48
# rss设置
rss: atom.xml
open_graph:
  fb_app_id:
  fb_admins:
  twitter_id:
  google_plus:
# disqus评论,默认不开启,需FQ
disqus:
  enabled: false
  shortname: cactus-1
# 谷歌统计
google_analytics:
  enabled: false
  id: UA-86660611-1
# 百度统计
baidu_analytics:
  enabled: false
  id: 2e6da3c375c8a87f5b664cea6d4cb29c

gravatar:
  email: xiaobin_wu@yahoo.com

valine:
  enable: true
  app_id: xxxxxx
  app_key: xxxxxxx

Valine评论系统

themes/cactus/_config.yml配置Valine,需要申请app_id,app_key

valine:
  enable: true
  app_id: xxxx
  app_key: xxxx

themes/cactus/layout/_partial/comments.ejs,写入

<% if(theme.valine.enable) { %>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src='//unpkg.com/valine/dist/Valine.min.js'></script>
    <div id="vcomments" class="blog-post-comments"></div>
    <script>
        new Valine({
            el: '#vcomments',
            visitor: true,
            appId: '<%=theme.valine.app_id %>',
            appKey: '<%=theme.valine.app_key %>',
            placeholder: 'ヾノ≧∀≦)o来啊,快活啊!',
            avatar: 'robohash'
        })
    </script>
<% } %>

自动部署hexo博客到阿里云服务器

创建仓库(远端服务器创建git仓库),可以使用ssh登入云服务器

mkdir blog.git && cd blog.git
git init --bare

Hexo配置

deploy:
  type: git
  message: update
  repo: root@xx.xxx.xx.xxx:/www/wwwroot/blog.git,master

插件安装

npm install hexo-deployer-git --save

自动部署

进入到git仓库hooks目录,并创建钩子post-receive

cd /www/wwwroot/blog.git/hooks
touch post-receive
vim post-receive

输入下面脚本:

#!/bin/bash -l
GIT_REPO=/www/wwwroot/blog.git
TMP_GIT_CLONE=/www/wwwroot/tmp/blog
PUBLIC_WWW=/www/wwwroot/blog
rm -rf ${TMP_GIT_CLONE}
mkdir ${TMP_GIT_CLONE}
git clone $GIT_REPO $TMP_GIT_CLONE
rm -rf ${PUBLIC_WWW}/*
cp -rf ${TMP_GIT_CLONE}/* ${PUBLIC_WWW}

更改权限

chmod +x post-receive
chmod 777 -R /www/wwwroot/blog
chmod 777 -R /www/wwwroot/tmp/blog

最后部署

$ hexo g -d
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
个人网站一共有8个页面。首先博客的登录界面login.html:是利用html5和css3结合写出的一个超炫酷的页面,根据canvas粒子制作出背景具有动态的效果。登陆后根据存入数据进行比对,对其用户名、密码、验证码验证,只有通过验证后才能登录成功并且验证成功后可以达到全屏的效果。每一个页面分为footer body和footer三部分组成。头部主要就是标题栏,尾部是页脚,中间就是主题内容。index.html主页:主要就利用js焦点滚动式轮播插入图片和文字自行进行翻页,其他主要利用div和css进行控制每一个内容框。利用链接跳转到相对应的内容上。可以根据标题、标签、关键字等点击到另一个内容,图片和文字进行有个布局达到图文环绕的布局。再然后,就是 关于about.html页面:博主简介利用jquery焦点缩略图轮播滚动类似选项卡滑动切换。可以自动展现不同的图片。其次,是成长页面about.html:是博主对未来的美好未来的期待,利用bootstrap响应式布局进行布局,图片和文章不同布局相结合,是整体更协调。再其次,是娱乐fun.html页面,利用CSS3 transform当鼠标悬停到照片上时,图片具有放大特效,主要利用css3中scale()和rotate()进行旋转和缩放。接下来是说说moodlist.html:个人心情页面,博主可以发一些类似于微信或qq心情说说,具有时间年轮的效果,当鼠标放上某一个时具有高亮的效果。最后是留言comment.html页面,可以通过给博主留言。给博主一些意见,该留言可以有表情添加,留言框带有头像。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值