【问题标题】:My Liquid tag is not recognized by GitHub pagesGitHub 页面无法识别我的 Liquid 标签
【发布时间】:2019-06-27 05:02:26
【问题描述】:

我使用 Jekyll 3.8.5 并在 GitHub 上建立了一个博客。我还使用了Jekyll-Katex 0.3.0,这是一个 Jekyll 插件,用于通过 KaTeX 轻松进行服务器端数学渲染。在我的本地机器上一切正常。但是当我将它推送到 GitHub 时,我得到了这样的信息:“您的网站在构建时遇到问题:_posts/2019-01-22-ECDSA-and-Bitcoin-I.md 中第 11 行的标签 Katexmm 不是公认的 Liquid 标签。”

“Katexmm”是liquid tag of Jekyll-Katex,所以我检查了依赖项。 Jekyll-Katex 0.3.0 requires Jekyll ~> 3.8GitHub Pages uses Jekyll 3.7.4。我想这就是问题所在。

我该怎么办? 还有一件事:我想使用“katexmm”,请不要建议我使用 Jekyll 3.7.4 而不是 3.8.5。 提前致谢。

我听从了 ashmaroli 的建议,但还是不行。我尝试了 Nelify 并“部署失败”:

11:31:01 AM: Build ready to start
11:31:03 AM: build-image version: 84aca9ba39e0ee86ba194760fbfc51a808f62543
11:31:04 AM: buildbot version: 57d44fd1631cc3fff8b38fbaf88d3d04f946418a
11:31:04 AM: Fetching cached dependencies
11:31:04 AM: Starting to download cache of 254.7KB
11:31:04 AM: Finished downloading cache in 147.184771ms
11:31:04 AM: Starting to extract cache
11:31:04 AM: Failed to fetch cache, continuing with build
11:31:04 AM: Starting to prepare the repo for build
11:31:04 AM: No cached dependencies found. Cloning fresh repo
11:31:04 AM: git clone https://github.com/Jun-Wang-2018/Blog
11:31:05 AM: Preparing Git Reference refs/heads/gh-pages
11:31:06 AM: Starting build script
11:31:06 AM: Installing dependencies
11:31:08 AM: Downloading and installing node v8.15.0...
11:31:08 AM: Downloading https://nodejs.org/dist/v8.15.0/node-v8.15.0-linux-x64.tar.xz...
11:31:08 AM:      0.0%
11:31:08 AM: 
######
11:31:08 AM:                    8.4%
11:31:08 AM: 
#############################################
11:31:08 AM: ###                          66.8%
11:31:08 AM: 
######################################
11:31:08 AM: ################################## 100.0%
11:31:08 AM: Computing checksum with sha256sum
11:31:08 AM: Checksums matched!
11:31:11 AM: Now using node v8.15.0 (npm v6.4.1)
11:31:12 AM: Attempting ruby version 2.3.6, read from environment
11:31:13 AM: Using ruby version 2.3.6
11:31:15 AM: Using PHP version 5.6
11:31:15 AM: Started restoring cached ruby gems
11:31:15 AM: Finished restoring cached ruby gems
11:31:15 AM: Installing gem bundle
11:31:15 AM: You must use Bundler 2 or greater with this lockfile.
11:31:15 AM: Error during gem install
11:31:15 AM: Error running command: Build script returned non-zero exit code: 1
11:31:15 AM: Failing build: Failed to build site
11:31:15 AM: failed during stage 'building site': Build script returned non-zero exit code: 1
11:31:15 AM: Finished processing build request in 11.629358799s

我尝试了 Cloudcannon 并且“Jekyll 构建失败”:

Syncing raw files... done
Checking existing local bundle state... failed
Loading gem cache... 
Checking gem cache (bundle_cache/A16MrNFnrU9wWPnsPr5G8PkR_kBFEHG0ytrPjGtZ7mQ.zip)... no cache

$ export JEKYLL_ENV="production"

$ ruby -v

ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]

$ bundle -v

Bundler version 1.16.6

$ bundle config --global jobs 4

Configured concurrent installs!

$ bundle install

Using local cacheable path...
You must use Bundler 2 or greater with this lockfile.

【问题讨论】:

标签: jekyll github-pages katex


【解决方案1】:

我的问题终于解决了。 我使用了另一个具有惊人主题“Next”的静态生成器 Hexo,它与 KaTeX 配合得很好。

My site snapshot

My site

解决问题的两个主要步骤:

步骤 1. 安装 Hexo 并将我的网站部署到 GitHub

第 2 步。嵌入 KaTex

每一步都有一些细节。我写了两个帖子: Step 1, Step 2.

【讨论】:

    【解决方案2】:

    由于 GitHub Pages 仅支持有限的一组 Ruby Gem (https://pages.github.com/versions/),因此推荐的方法是在本地构建并将目标文件夹(默认为 ./_site)的内容推送到远程进行托管。
    但是,这需要a bit of work to set up,因为您已经设置了一个存储库以从master 分支构建。

    相对更容易的路线是完全放弃 GitHub Pages 以使用第三方播放器,例如 NetlifyCloudcannon 等,具体取决于您的用例。

    Netlify 部署陷阱

    • jekyll-katex-0.3.0 至少需要 Ruby 版本 2.5.1。因此,您必须配置 Netlify 才能使用该版本。最简单的方法是定义一个环境变量RUBY_VERSION,并将值设置为2.5.1
    • 另一个问题是 Bundler 版本。 Netlify 似乎没有使用/安装Bundler-2.0。所以,要么
      • 使用旧版本的 Bundler 在本地生成 Gemfile.lock,或者
      • 从存储库中删除现有的Gemfile.lock。 (将 Gemfile.lock 添加到 .gitignore 文件将防止它被提交回)。
    • Netlify 似乎无法按预期使用 baseurl 配置。您必须将其设置为空字符串或null

    【讨论】:

    • 谢谢,ashmaroli。我试过你的方法,但它不起作用。在 cloudcannon 中,jekyll 构建失败。在 Netlify 中,部署失败。
    • Netlify 部署日志中的失败信息是什么?
    • 我刷新了我原来的帖子,见上文。
    • 错误来自 Bundler 版本差异。您可以通过从存储库中删除 Gemfile.lock 来解决此问题。
    • 我删除了 Gemfile.lock,它更好,但仍然有一个依赖错误:Yikes!看起来您没有安装 jekyll-katex 或其依赖项之一。为了使用当前配置的 Jekyll,你需要安装这个 gem。来自 Ruby 的完整错误消息是:'cannot load such file -- jekyll-katex' 如果遇到问题,您可以在 jekyllrb.com/help 找到有用的资源!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 2015-12-26
    相关资源
    最近更新 更多