代码之家  ›  专栏  ›  技术社区  ›  Sach

如何在GitHubPages中安装/使用Jekyll插件?

  •  1
  • Sach  · 技术社区  · 6 年前

    this 一个。它在新选项卡中打开链接,默认情况下,在 Markdown .

    myusername.github.io repo,将其克隆到本地,并使用 jekyll new . 按指示 here

    然后,为了安装上述插件,我遵循了帮助部分中提到的步骤,即以下内容:


    Add the following to your site's Gemfile
    
    gem 'jekyll-target-blank'
    
    and add the following to your site's _config.yml
    
    plugins:
      - jekyll-target-blank
    

    另外,请注意,默认情况下 Gemfile 包含以下部分和说明:

    # This will help ensure the proper Jekyll version is running.
    # Happy Jekylling!
    gem "jekyll", "~> 3.8.3"
    
    # This is the default theme for new Jekyll sites. You may change this to anything you like.
    gem "minima", "~> 2.0"
    
    # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
    # uncomment the line below. To upgrade, run `bundle update github-pages`.
    # gem "github-pages", group: :jekyll_plugins
    

    所以我换了 Gemfile公司 bundle update github-pages .

    Gemfile公司 看起来是这样的:

    source "https://rubygems.org"
    
    # Hello! This is where you manage which Jekyll version is used to run.
    # When you want to use a different version, change it below, save the
    # file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
    #
    #     bundle exec jekyll serve
    #
    # This will help ensure the proper Jekyll version is running.
    # Happy Jekylling!
    # gem "jekyll", "~> 3.8.3"
    
    # This is the default theme for new Jekyll sites. You may change this to anything you like.
    gem "minima", "~> 2.0"
    
    # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
    # uncomment the line below. To upgrade, run `bundle update github-pages`.
    gem "github-pages", group: :jekyll_plugins
    
    # If you have any plugins, put them here!
    group :jekyll_plugins do
      gem "jekyll-feed", "~> 0.6"
      gem 'jekyll-target-blank'
    end
    
    # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
    gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
    
    # Performance-booster for watching directories on Windows
    gem "wdm", "~> 0.1.0" if Gem.win_platform?
    

    注意,我已经注释/取消注释了正确的部分。

    还有我的 _config.yml 看起来像这样:

    title: xxxxxx
    email: xxxxxx
    description: >- # this means to ignore newlines until "baseurl:"
      xxxxxx.
    baseurl: "" # the subpath of your site, e.g. /blog
    url: "" # the base hostname & protocol for your site, e.g. http://example.com
    
    github_username:  xxxxxx
    instagram_username: xxxxxx
    
    # Build settings
    markdown: kramdown
    theme: minima
    plugins:
      - jekyll-feed
      - jekyll-target-blank
    

    然后我做了一个

    bundle exec jekyll serve
    

    在本地运行 http://127.0.0.1:4000/ 这个插件工作得很好。通过单击下面编写的链接,它将按原样在新选项卡中打开链接。

    [LinkText](link)
    

    但是,当我把它全部推到GitHub时,插件不起作用。它仍然打开同一选项卡上的链接。

    我做错什么了?

    2 回复  |  直到 6 年前
        1
  •  2
  •   Keith Mifsud    6 年前

    我是Jekyll Target Blank的开发者。GH页面只支持一些插件 https://help.github.com/articles/adding-jekyll-plugins-to-a-github-pages-site/ . 我已经要求这个插件成为支持,但他们的反应是一个可能。

        2
  •  1
  •   takacsmark    6 年前

    GitHub页面使用Kramdown,Jekyll 3中的默认降价处理器。你可以用克莱姆敦做这个:

    [link](url){:target="_blank"}

    如果您使用的是最新的GitHub页面版本,那么它也应该适合您。

    如果这不起作用,您可以始终在标记文件中使用纯HTML,并添加目标为空的类似链接。