美文网首页
FreeBSD Jekyll 创建 myblog 站点

FreeBSD Jekyll 创建 myblog 站点

作者: 偷油考拉 | 来源:发表于2022-03-23 23:11 被阅读0次

准备工作

  • 在 jekyll 用户下运行
  • gem jekyll 安装好
  • 安装好 rouge gem install kramdown rouge
$ gem -v
3.0.8

$ jekyll -v
jekyll 4.2.0

创建站点 myblog

执行命令 jekyll new myblog,新建站点 myblog

$ jekyll new myblog
Running bundle install in /usr/home/jekyll/myblog... 
  Bundler: Fetching gem metadata from https://rubygems.org/..........
  Bundler: Resolving dependencies...
  Bundler: Using public_suffix 4.0.6
  Bundler: Fetching addressable 2.8.0Bundler::PermissionError: There was an error while trying to write to
  Bundler: `/usr/local/lib/ruby/gems/2.7/cache/addressable-2.8.0.gem`. It is likely that
  Bundler: you need to grant write permissions for that path.
  Bundler: An error occurred while installing addressable (2.8.0), and Bundler cannot
  Bundler: continue.
  Bundler: Make sure that `gem install addressable -v '2.8.0' --source
  Bundler: 'https://rubygems.org/'` succeeds before bundling.
  Bundler: 
  Bundler: In Gemfile:
  Bundler: minima was resolved to 2.5.1, which depends on
  Bundler: jekyll-feed was resolved to 0.15.1, which depends on
  Bundler: jekyll was resolved to 4.2.0, which depends on
  Bundler: addressable

查看myblog文件

$ ls myblog/
404.html    Gemfile     _config.yml _posts      about.markdown  index.markdown

安装主题 themes

配置Gemfile,追加如下内容:

# Gem install themes
gem "minimal-mistakes-jekyll"
gem "just-the-docs"
gem "jekyll-theme-simplex"

这样,我们就有4个主题:minima(default)、minimal-mistakes-jekylljust-the-docsjekyll-theme-simplex

root用户执行命令bundle,获取/升级 gems

root@VM-0-8-freebsd:/usr/home/jekyll/myblog # bundle
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
... 省略 ...
Bundle complete! 9 Gemfile dependencies, 52 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

通过gem list --local可以查看到刚才安装主题的gem包。

通过bundle info --path $theme_name查看安装的主题,可以看到都安装在/usr/local/lib/ruby/gems/2.7/gems/目录下,与CentOS不同。如下:

$ bundle info --path minima
/usr/local/lib/ruby/gems/2.7/gems/minima-2.5.1
$ bundle info --path minimal-mistakes-jekyll
/usr/local/lib/ruby/gems/2.7/gems/minimal-mistakes-jekyll-4.24.0
$ bundle info --path just-the-docs
/usr/local/lib/ruby/gems/2.7/gems/just-the-docs-0.3.3
$ bundle info --path jekyll-theme-simplex
/usr/local/lib/ruby/gems/2.7/gems/jekyll-theme-simplex-0.9.8.15

配置使用主题

配置 _config.yml

# Build settings
#theme: minima
theme: minimal-mistakes-jekyll 
#theme: just-the-docs
#theme: jekyll-theme-simplex

更新主题
jekyll 用户执行 bundle update

$ bundle update
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
... 省略 ...
Using jekyll-theme-simplex 0.9.8.15
Using just-the-docs 0.3.3
Using minima 2.5.1
Using minimal-mistakes-jekyll 4.24.0
Bundle updated!

配置监听端口

配置 _config.yml,增加如下:

# Serving
host: 0.0.0.0

配置markdown

安装 rouge

gem install kramdown rouge

配置_config.yml

markdown: kramdown
highlighter: rouge

kramdown:
  input: GFM
  syntax_highlighter: rouge

rouge创建css文件,在当前站点目录下

mkdir -p assets/css/
rougify style thankful_eyes > assets/css/syntax.css

修改index.markdown,指定引用layout;创建被指定引用的layout,指定引用includes/markdown.html;创建_includes/markdonw.html , 引用rouge创建的css文件

mkdir _layouts
mkdir _includes

启动jekyll

  • jekyll build 编译,并将静态文件输出到 _site 目录
$ jekyll build
Configuration file: /usr/home/jekyll/myblog/_config.yml
            Source: /usr/home/jekyll/myblog
       Destination: /usr/home/jekyll/myblog/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
     Build Warning: Layout 'post' requested in _posts/2021-09-10-welcome-to-jekyll.markdown does not exist.
     Build Warning: Layout 'page' requested in about.markdown does not exist.
                    done in 1.123 seconds.
 Auto-regeneration: disabled. Use --watch to enable.

  • 在myblog目录,执行启动命令 nohup bundle exec jekyll serve --livereload &,如下:
$ nohup bundle exec jekyll serve  --livereload &
$ appending output to nohup.out

$ ls
404.html    Gemfile     Gemfile.lock    _config.yml _posts      _site       about.markdown  index.markdown  nohup.out

  • 检查端口,运行于本地的4000,35729端口
$ netstat -4an
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address          Foreign Address        (state)
tcp4       0      0 *.35729                *.*                    LISTEN
tcp4       0      0 *.4000                 *.*                    LISTEN
tcp4       0     52 172.17.0.8.1984        183.195.89.93.12194    ESTABLISHED
tcp4       0      0 172.17.0.8.1984        183.195.89.93.12056    ESTABLISHED
tcp4       0      0 *.1984                 *.*                    LISTEN
tcp4       0      0 *.80                   *.*                    LISTEN
tcp4       0      0 127.0.0.1.25           *.*                    LISTEN
udp4       0      0 *.514                  *.*                    
               

相关文章

  • FreeBSD Jekyll 创建 myblog 站点

    准备工作 在 jekyll 用户下运行 gem jekyll 安装好 安装好 rouge gem install...

  • 基于Jekyll和GitHub Pages搭建个人博客

    本文介绍如何利用Jekyll创建一个静态站点,并托管到GitHub Pages上。 JeKyll JeKyll是一...

  • 开始旅程

    欢迎 该站点的目标是成为jekyll的全面指南。包括一些内容如:搭建和运行你的站点,创建以及管理内容、定制站点的展...

  • 使用GitHub Pages搭建个人博客

    创建用于个人站点的repository 选择主题 Jekyll官方有很多主题, 可自行选择 此时进入主页 ,便可查...

  • Jekyll Now

    Jekyll Now Jekyll是一个静态站点生成器,非常适合于GitHub托管的博客([jekyll存储库](...

  • Jekyll安装

    关于Jekyll Jekyll是一个静态站点生成器。 Requirements Ruby RubyGems GCC...

  • django入门

    第一步,创建项目打开编辑器,输入Django-admin startproject myblog //myblog...

  • Django的hello word 网页

    一、创建应用 e:\project\myblog>python manage.py startapp blog 在...

  • Windows上安装Jekyll

    介绍Jekyll jekyll是一个简单的免费的Blog生成工具,是一个静态站点生成器,它会根据网页源码生成静态文...

  • 初入Django

    命令行输入:django-admin startproject myblog将自动创建文件 创建应用(需要进入my...

网友评论

      本文标题:FreeBSD Jekyll 创建 myblog 站点

      本文链接:https://www.haomeiwen.com/subject/jwgwwltx.html