Below you will find pages that utilize the taxonomy term “Jekyll”
January 26, 2022
jekyll post page 生成脚本
脚本功能:
- md 文件创建
- md 头内容生成
- 生成随机短地址作为permalink,以便为每个page实现固定地址
脚本内容:
#!/usr/bin/env bash
DIR="${0%/*}"
title=`echo $@ | sed 's/[ ][ ]*/-/g'`
post_date=`date +"%Y-%m-%d %T"`
post_name="`date "+%Y-%m-%d"`-${title}.markdown"
random_addr=`openssl rand -hex 8 | md5 | cut -c1-8`
cat > ${DIR}/../_posts/${post_name} << EOF
---
layout: post
title: "${title}"
description: ""
date: ${post_date} +0800
categories: default
permalink: /posts/${random_addr}/
tags: [writing]
---
EOF
使用方法:
./new_post.sh <the new page name>
January 23, 2022
jekyll静态blog部署 checklist
-
安装jekyll
1.1 安装ruby
为了避免版本冲突问题,使用rbenv进行安装(以ubuntu为例,参考https://gorails.com/setup/ubuntu/18.04)
-
安装rbenv
cd git clone https://github.com/rbenv/rbenv.git ~/.rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL -
安装ruby
rbenv install 3.0.3 rbenv global 3.0.3检查安装是否符合预期
ruby -v -
安装 Bundler
gem install bundler
1.2 安装jekyll
gem install jekyll bundler -
-
创建blog project
方案一: 安装好ruby后,安装jekyll,并创建blog project:
gem install bundler jekyll jekyll new myblog方案二:直接选择自己喜欢的主题,从github将项目克隆到本地