Github 页面无法正确显示 markdown

Github pages cannot display markdown correctly

我正在使用 github pages + jekyll 建立我的博客。

在推送我的最新提交之前它工作正常。此提交添加了一个 cname 文件并仅编辑了一些单词,而没有对我网站的架构进行任何更改。

-    <h3 class="description">aaaaaaaaaa</h3>
+    <h3 class="description">bbbbbbbbbb</h3>

在那之后降价没有正确出现。

当我写#head1 的时候。不出现title head1,直接出现#head1。

但是,如果我在 localhost:4000 中使用 jekyll serve build,它会正确显示。

这是我的_config.yml:

markdown: kramdown
markdown_ext: markdown,mkd,mkdn,md
textile_ext: textile
highlighter: pygments

知道是什么导致了这个错误吗?

GitHub jekyll 也支持 markdown。
首先使用 .md 扩展名

重命名您的文件

如果您的文件夹中有 .nojekyll,它将禁用 njekyll。

确认您没有这是您的文件夹。


阅读docs && GitHub relevant doc如何准备和部署


Running Jekyll

Use the command git checkout to switch to the default branch that the GitHub Pages build server uses to generate your site. The default branch you switch to depends on the type of GitHub Pages site you're building.

For Project Pages sites, switch to gh-pages. For User Pages or Organization Pages sites, switch to master. For more information, see "User, Organization, and Project Pages".

Use the command bundle exec jekyll serve in the root of your repository to run the GitHub Pages build server with Bundler.

bundle exec jekyll serve Navigate to http://localhost:4000 to see your local site.

已更新!

这很可能是由于 Jekyll 3 upgrade on GitHub Pages

从 2016 年 5 月 1 日起,GitHub 将不再支持 rdiscountredcarpet。此外,自 2 月 1 日起,GitHub Pages 仅支持 rouge:

Starting May 1st, 2016, GitHub Pages will only support kramdown, Jekyll's default Markdown engine.

GitHub Pages now only supports Rouge.

你可以看看这个here

处理方法如下:

首先,按照 上的说明进行尝试。而不是 #Heading 你会写 # Heading.

其次,调整您的 _config.yml:将 highlightermarkdown 更改为

highlighter: rouge
markdown: kramdown
kramdown:
  input: GFM

第三,要在本地构建站点,请使用 Bundler, the method recommended by GitHub:

  1. 安装捆绑器:

    gem install bundler
    
  2. 然后 运行 bundle update - 这将更新你所有的 gem,包括 github-pages,如果你已经有了这个 gem 在本地安装。

  3. 然后,创建一个Gemfile(不带任何文件扩展名),内容如下:

    source 'https://rubygems.org' 
    gem 'github-pages'
    

将其保存到项目的根目录。

  1. 然后,运行 bundle install 在您的项目上。这将创建一个名为 Gemfile.lock 的文件,并将 安装所有必需的 gem 及其依赖项

  2. 最后,运行 bundle exec jekyll serve --watch 您将能够在本地查看您的网站,就像在线查看一样(在 GitHub 上托管时) .

到时候你应该没事了!


PS。如果您的项目需要更多 gem,例如 jekyll-paginatejekyll-mentions,您需要将它们添加到 Gemfile,例如:

source 'https://rubygems.org' 
gem 'github-pages'
gem 'jekyll-paginate'

此外,将它们添加到您项目的 _config.yml:

gems:
  - jekyll-paginate
  - jekyll-mentions

在这里您会看到 gem versions currently supported by GitHub Pages. Here you read about Upgrading Jekyll 2 to 3.

的列表

希望对您有所帮助!

一点观察 运行 我自己的 Jekyll 支持 github 页博客,

代表标题大小的 # 和标题文本之间的 space 很重要,否则降价将不会按预期显示。因此,对于您的示例,我会将降价标题显示为

# Zookeeper Atomic Broadcast for heading 1

## Zookeeper Atomic Broadcast for heading 2

### Zookeeper Atomic Broadcast for heading 3

#### Zookeeper Atomic Broadcast for heading 4

##### Zookeeper Atomic Broadcast for heading 5