• Hexo搭建静态博客踩坑日记(一)


    前言

    博客折腾一次就好, 找一个适合自己的博客平台, 专注于内容进行提升.

    • 方式一: 自己买服务器, 域名, 写前端, 后端(前后分离最折腾, 不分离还好一点)...
    • 方式二: 利用Hexo, Hugo 等快速搭建静态博客, 找主题, 个性化主题...
    • 方式三: 在github上寻找博客园主题...
    • 方式四: 土豪去CSDN买皮肤吧...
    • 方式五: 富二代可以不写博客...

    起步

    Hexo的基本环境准备

    • node.js
    • git

    Hexo安装

    • 打开terminal

    mac 系统推荐使用terminal ( 切换root权限, sudo su)
    win 系统推荐使用 win+r cmd (管理员打开) or 任意目录右键 git bash here

    # 确保npm已经安装
    >> npm -v
    6.13.2
    # 确保git已经安装
    >> git version
    git version 2.23.0
    
    # 安装cnpm 淘宝镜像(增加下载速度, 也可以不安装, 代码替换为npm)
    >> npm install cnpm -g --registry=https://registry.npm.taobao.org
    
    # 全局安装hexo
    >> cnpm install hexo-cli -g
    

    Hexo初始化项目

    • hexo安装成功, 选择一个文件夹初始化hexo

    ( eg-->文件夹名称: blog)

    # 进入blog文件夹
    >> cd blog
    # 初始化hexo
    >> hexo init
    
    • blog文件夹多了以下内容,博客所需要的依赖环境
    #博客文件目录
    node_modules	#hexo 所依赖的node模块,插件 
    scaffolds
    source			#文章的资源目录
    themes			#hexo 的主题目录
    .gitignore
    _config.yml		#hexo根目录配置文件,接下来会细说
    package.json
    package-lock.json
    
    • 浏览博客
    # 启动hexo server
    >> hexo s
    INFO  Start processing
    INFO  Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
    

    Hexo部署项目

    • 部署github or gitee 的准备工作
    # 在github or gitee 项目下创建一个与用户名相同的项目, 这样此项目可由公网直接访问.
    
    # github
    访问地址: https://用户名.github.io
    优点: 不用反复部署, 推送及展示.
    缺点: 国外服务器, 访问慢. 
    
    # gitee 
    访问地址: https://用户名.gitee.io
    优点: 国内, 访问速度快
    缺点: 每次部署需要点击-->服务-->page服务部署 (开会员可忽略,90RMB/year)
    
    
    • 部署到github or gitee

    首先修改blog文件夹下的配置文件_config.yml 里的以下代码片段

    # Site 站点基本配置
    title: #网站标题
    subtitle: #网站副标题
    description: #网站描述
    keywords: #全局文章关键字配置
    author: #作者名称
    language: #语言配置
    timezone:	#时区(可不配置)
    
    # URL 项目部署配置
    # If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
    url: # 你的github URL(https://用户名.github.io) 或者 gitee URL(https://用户名.gitee.io)
    root: #项目发布目录
    permalink: :year/:month/:day/:title/
    permalink_defaults:
    
    ......
    ......
    ......
    
    #Deployment
    ## Docs: https://hexo.io/docs/deployment.html
    deploy:
      type: git
      # 可手动去github or gitee点击 克隆/下载  复制地址 
      repo: https://gitee.com/用户名/项目名.git
      branch: master
    

    执行命令, 部署到github or gitee

    # 部署 hexo
    >> hexo d
    

    这里会让你输入github or gitee 用户名和密码, 之后直接强制推送, 推送成功后, 检查远程仓库是否推送成功, github即可访问url查看你的博客, gitee 需要打开项目-->服务-->page服务-->部署-->得到项目运行地址.


    后记

    这样最基本的静态博客就搭建好了, 更换主题请看--> Hexo搭建静态博客踩坑日记(二)

  • 相关阅读:
    CodeForces 659F Polycarp and Hay
    CodeForces 713C Sonya and Problem Wihtout a Legend
    CodeForces 712D Memory and Scores
    CodeForces 689E Mike and Geometry Problem
    CodeForces 675D Tree Construction
    CodeForces 671A Recycling Bottles
    CodeForces 667C Reberland Linguistics
    CodeForces 672D Robin Hood
    CodeForces 675E Trains and Statistic
    CodeForces 676D Theseus and labyrinth
  • 原文地址:https://www.cnblogs.com/quaint/p/12273536.html
Copyright © 2020-2023  润新知