Create your own blog and use Gitee Hexo

First, install Git and Node

(A) mounting Git

  • Git installed under Windows:

    Install Git on Windows is simple, but therefore more than narrative.

  • Git installed under Linux:

    Use Linux package management tools installed, such as Yum, sudo yum install git.

  • Git installed under Mac:

    Git on Mac can be installed either by way of the GUI can also be installed by Command of the way, using the Homebrew to install: sudo brew install git. If you do not HomBrew installed, you can refer https://brew.sh/index_zh-cn

  • Git proxy-related:

    • View the current proxy settings:

      git config --global http.proxy
      git config --global https.proxy
    • The current proxy settings:

      git config --global http.proxy 'http://127.0.0.1:1080'
      git config --global https.proxy 'http://127.0.0.1:1080'

      or:

      git config --global http.proxy 'socks5://127.0.0.1:1080'
      git config --global https.proxy 'socks5://127.0.0.1:1080'
    • Delete Agent:

      git config --global --unset http.proxy
      git config --global --unset https.proxy

(B) mounting Node

  • In Windows installed Node:

    Node installed on Windows is simple, but therefore more than narrative.

  • Node installed on Linux:

    • Tar.gz NodeJs official website to download the compressed file system Linux

    • Extract the files to a specified directory, where to / home / blue / applications directory, for example

      tar -xvf node-v10.16.0-linux-x64.tar.xz
      mv node-v10.16.0 /home/blue/applications
      ln -s /home/blue/applications/node /home/blue/applications/node
    • Modify the permissions of the executable file:

      chmod -R 755 /home/blue/applications/node-v10.16.0
      chmod -R 755 /home/blue/applications/node
    • Test execution

      node -v
      npm -v
  • Node installed on the Mac:

    Node provides a GUI mode for the Mac, but we can also be installed by HomeBrew:

    sudo brew install node
  • Node Settings:

    • Ali settings using NPM Source:

      npm config set registry https://registry.npm.taobao.org --global
      npm config set disturl https://npm.taobao.org/dist --global

      Yarn is disposed below (to be later installed Yarn):

      yarn config set registry 'https://registry.npm.taobao.org'
    • Set NPM cache:

      npm config set prefix "/home/blue/applications/cache/node/prefix"
      npm config set cache "/home/blue/applications/cache/node/cache"

      Also you need to /home/blue/applications/cache/node/prefixadd to the PATH environment variable

    • Use Yarn:

      npm install -g yarn

Second, create a remote repository and install Hexo

  • Installation Hexo:sudo npm install -g hexo

  • Install the necessary plug-ins:npm install hexo-renderer-jade hexo-renderer-stylus --save

  • Create a local warehouse

    cd ~/Code
    mkdir bluemiaomiao
    cd bluemiaomiao
    hexo init
    git init
  • Creating a remote repository

    git add remote origin <YOUR_GIT_REPO_ADDRESS>
  • Install theme

    git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly
    rm -rf /themes/landscape
  • Hexo configuration _config.yml

    # 配置网站的标题
    title: 爱吃糖的蓝胖子de官方博客
    # 配置网站的子标题
    subtitle: bluemiaomiao.github.io
    # 配置网站的表述信息
    description: 一个Sre攻城狮的奋斗历程
    keywords:
    # 配置网站的作者名称
    author: BlueMiaomiao
    # 配置网站的语言为中文
    language: zh-CN
    # 配置网站的时区为中国北京时间
    timezone: Asia/Shanghai
    
    # 配置站点发布的URL地址
    url: http://bluemiaomiao.github.io
    root: /
    permalink: :year/:month/:day/:title/
    permalink_defaults:
    
    source_dir: source
    # 配置静态文件的生成目录,在Gitee部署时需要使用
    public_dir: docs
    tag_dir: tags
    archive_dir: archives
    category_dir: categories
    code_dir: downloads/code
    i18n_dir: :lang
    skip_render:
    
    new_post_name: :title.md
    default_layout: post
    titlecase: false
    external_link: true
    filename_case: 0
    render_drafts: false
    post_asset_folder: false
    relative_link: false
    future: true
    highlight:
    enable: true
    line_number: true
    auto_detect: false
    tab_replace:
    
    index_generator:
    path: ''
    per_page: 10
    order_by: -date
    
    default_category: uncategorized
    category_map:
    tag_map:
    
    date_format: YYYY-MM-DD
    time_format: HH:mm:ss
    
    per_page: 10
    pagination_dir: page
    
    # 配置使用的主题
    theme: Butterfly
    
    deploy:
    type:
  • Theme configuration

    mkdir source/_data
    cp themes/Butterfly/_config.yml source/_data/_butterfly.yml
    menu:
    主页: /||fa fa-home
    时间轴: /archives/||fa fa-archive
    标签: /tags/||fa fa-tags
    分类: /categories/||fa fa-folder-open
    友链: /link/||fa fa-link
    关于: /about/||fa fa-heart
    
    favicon: /img/favicon.ico
    
    highlight_theme: pale night
    highlight_copy: true
    
    code_word_wrap: true
    
    social:
    fa fa-home: https://bluemiaomiao.gitee.io/
    fa fa-github: https://github.com/bluemiaomiao
    fa fa-gitlab: https://gitee.com/bluemiaomiao
    fa fa-plane: https://blog.51cto.com/xvjunjie
    fa fa-rocket: https://www.cnblogs.com/bluemiaomiao
    fa fa-rss: https://blog.nowcoder.net/bluemiaomiao
    
    algolia_search:
    enable: false
    hits:
        per_page: 6
    
    labels:
        input_placeholder: Search for Posts
        hits_empty: "We didn't find any results for the search: ${query}" # if there are no result
        hits_stats: "${hits} results found in ${time} ms"
    
    local_search:
    enable: false
    labels:
        input_placeholder: Search for Posts
        hits_empty: "We didn't find any results for the search: ${query}" # if there are no result
    
    mathjax:
    enable: false
    cdn: https://cdn.jsdelivr.net/npm/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML
    
    katex:
    enable: false
    cdn:
        css: https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css  
    hide_scrollbar: true
    
    google_analytics:
    
    stylesheets:
    - /css/index.css
    
    scripts:
    - /js/utils.js
    - /js/main.js
    
    cdn:
    css:
        fontawesome: https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css
        googlefont: https://fonts.googleapis.com/css?family=Titillium+Web
        fancybox: https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css
    js:
        jquery: https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js
        fancybox: https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js
        js-cookies: https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js
        lozy: https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js
    
    avatar: /img/avatar.png
    
    top_img: /img/year-28.jpg
    
    post_img: https://cdn.jsdelivr.net/gh/jerryc127/CDN@latest/Photo/post.png
    
    default_cover: https://cdn.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png
    
    archive_img: https://cdn.jsdelivr.net/gh/jerryc127/CDN@latest/Photo/archive.jpg
    
    lodding_bg:
    flink: /img/friend_404.gif
    post_page: /img/404.jpg
    
    post_meta:
    date_type: both 
    categories: true 
    tags: true
    
    wordcount:
    enable: true
    
    toc:
    enable: true
    number: false
    
    auto_open_sidebar:
    enable: false
    
    post_copyright:
    enable: true
    license: CC BY-NC-SA 4.0
    license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/
    
    auto_excerpt:
    enable: true
    length: 150
    
    addThis:
    enable: false
    pubid:
    
    sharejs:
    enable: true
    sites: facebook,twitter,wechat,weibo,qq
    
    addtoany:
    enable: false
    item:
        - facebook
        - twitter
        - wechat
        - sina_weibo
        - facebook_messenger
        - email
        - copy_link
    
    disqus:
    enable: false
    shortname: 
    
    valine:
    enable: false
    appId:   
    appKey:   
    notify: false 
    verify: false 
    pageSize: 10 
    avatar: monsterid 
    lang: en # i18n: zh-cn/en/tw
    placeholder: Please leave your footprints
    guest_info: nick,mail,link
    
    since: 2016
    
    footer_custom_text: 技术成就梦想, 实力铸就辉煌
    
    footer_copyright:
    enable: true
    
    ICP:
    enable: false
    url: 
    text:
    
    # 关闭数据统计功能
    busuanzi:
    site_uv: false
    site_pv: false
    page_pv: false
    
    google_site_verification:
    
    bing_site_verification:
    
    baidu_site_verification:
    
    qihu_site_verification:
    
    # 友情链接基础信息
    Flink:
    headline: 友情链接
    info_headline: 开始认识博主
    name: BlueMiaomiao
    address: bluemiaomiao.gitee.io
    avatar: https://jerryc.me/img/avatar.png
    info: 技术成就梦想, 实力铸就辉煌
    comment: 添加友链请留言
    
    # 是否显示整站运行的时间
    runtimeshow:
    enable: true
    start_date: 12/02/2016 12:30:00
    
    # 是否支持夜间模式
    nightshift:
    enable: true
    
    activate_power_mode:
    enable: false
    
    # 网站公告
    announcement:
    content: 博主邮箱:[email protected]/[email protected]
    
    # 是否打开文章赞赏功能
    reward:
    enable: true
    QR_code:
        - itemlist:
            img: /img/wechat-me.jpg
            text: 微信
        - itemlist:
            img: /img/alipay-me.jpg
            text: 支付宝
    
    # 文章自动推荐功能
    related_post:
    enable: false
    limit: 6
    
    canvas_ribbon:
    enable: false
    size: 150
    alpha: 0.6
    zIndex: -1
    click_to_change: false
    
    # 开启背景飘带功能
    canvas_ribbon_piao:
    enable: true
    
    # 避免网址重复SEO
    canonical: true
    
    # 禁止百度转码
    disable_baidu_transformation: true
    
    twitter_meta: true
    Open_Graph_meta: true
    
    # 阅读模式
    readmode:
    enable: true
    
    # 开启字体支持
    font:
    enable: false
    font-family: Lato, Helvetica Neue For Number, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, PingFang SC, Hiragino Sans GB,"Microsoft JhengHei", "MicrMicrosoft YaHei", Helvetica Neue, Helvetica, Arial, sans-serif
    code-font: consolas, Menlo, "PingFang SC", "Microsoft JhengHei","Microsoft YaHei", monospace, Helvetica Neue For Number
    
    # 水平分割线
    hr:
    enable: true
    icon: '\f21c'
    icon-top: -20px
    
    # 主页子标题
    subtitle: 
    enable: true
    sub1: 技术成就梦想, 实力铸就辉煌
    sub2: bluemiaomiao.gitee.io
    
    # 侧边功能模块设置
    aside:
    card_author: true
    card_announcement: true
    card_recent_post: true
    card_categories: true
    card_tags: true
    card_archives: true
    card_webinfo: false
    
    # 中文繁体假体自动转换
    translate:
    enable: true
    # 默认显示的语言
    default: 简
    #网站默认语言,1: 繁體中文, 2: 简体中文
    defaultEncoding: 2
    #延迟时间,若不在前, 要设定延迟翻译时间, 如100表示100ms,默认为0
    translateDelay: 0
    #博客网址
    cookieDomain: "https://bluemiaomiao.gitee.io/"
    #当文字是简体时,按钮的文本
    msgToTraditionalChinese: "繁"
    #当文字是繁体时,按钮的文本
    msgToSimplifiedChinese: "简"
    
    # 鼠标点击效果
    fireworks:
    enable: true
    
    #百度推送
    baidu_push:
    enable: false
  • Theme installation configuration file: https://jerryc.me/posts/21cfbf15/

  • Generate static pages:hexo g

  • Preview static pages:hexo s

  • Publish static pages:

    git add .
    git commit -m "init"
    git push origin masters
  • Create the same code repository gitee user name, enable Gitee Pages service, issued the master branch of the docs directory

  • Accessed using a browser: HTTPS: // <your_username> .gitee.io

Gitee of Pages service is a near real-time Httpd service, Hexo generated even if the articles posted to the code repository, not necessarily displayed by a browser, generally have a 30-minute delay.

Third, the commonly used commands Hexo

(A) common commands

  • hexo new "postName" # New Articles
  • hexo new page "pageName" # New Page
  • hexo generate # generate static pages to the public directory
  • hexo server # open preview access port (default 4000, 'ctrl + c' off server)
  • hexo deploy # deployed to GitHub
  • hexo help # view help
  • hexo version # version View Hexo

(B) simplified command

  • hexo n == hexo new
  • hexo g == hexo generate
  • hexo s == hexo server
  • hexo d == hexo deploy

(C) a combination of a command

  • hexo s -g # and locally generated preview
  • hexo d -g # Build and upload

Guess you like

Origin blog.51cto.com/xvjunjie/2424227