Cannot install “lanyon” jekyll theme

懵懂的女人 提交于 2019-12-12 02:03:28

问题


Before I begin this, some preface warning;

My knowledge of jekyll is 0. My knowledge of ruby is 0.

Though I do think I've done pretty well for having no experience and just stepping into it today. That said, this is all completely new to me.

I wanted to give it a try for my github pages for a blog, just to see if I could make it work. I am running into a huge issue with what I suppose would be called the global variables.

I downloaded Lanyon here; Lanyon

I did the following steps, in order, from my Windows 8.1 x64 machine.

  1. Installed python 3.4.1 (link)
  2. Installed ruby using the RailsInstaller (link)
  3. Installed rubygems using gem update --system from a PowerShell console
  4. created a new github repository
  5. created a gh-pages branch in that repository
  6. created a Gemfile in that branch, with the following text
source 'https://rubygems.org'
gem 'github-pages'

Then came the work with Lanyon.

  • downloaded Lanyon and extracted it, I copied all of the files into a new directory
  • pushed the entire directory to my repository on branch gh-pages
  • tried to navigate to the gh-pages given url.

Now I did see the index page, it did have the content, but the theme wasn't working. The css files were missing. Per the instructions for theme structure found on jekyll's website, I made some changes; link

  • I moved the head.html and sidebar.html into a new subfolder under _includes called themes/lanyon, per the suggested layout on the api docs.
  • I loved the css folder into a new folder called assets/themes/lanyon, again following those docs
  • I moved the files apple-touch-icon-144-precomposed.png, apple-touch-icon-precomposed.png, and favicon.ico into a new folder called assets/themes/lanyon/img, following the example in the api docs.

Now comes the trickiest part ... trying to get the {{ ASSET_PATH }} to work.

  • I looked at the file _includes/themes/lanyon/head.html and saw the 3 css assets had no variables.
  • I changed them to look like the following
<link rel="stylesheet" href="{{ ASSET_PATH }}/css/poole.css">
<link rel="stylesheet" href="{{ ASSET_PATH }}/css/syntax.css">
<link rel="stylesheet" href="{{ ASSET_PATH }}/css/lanyon.css">
  • I updated _config.yml to look like this, obviously filling in the [] variables instead.
# For more see: http://jekyllrb.com/docs/permalinks/
permalink: /:categories/:year/:month/:day/:title

exclude: [".rvmrc", ".rbenv-version", "README.md", "Rakefile", "changelog.md"]
pygments: true
markdown: redcarpet

title:            lanyon
tagline:          'lanyon theme'
author :
  name : Ciel
  email : stacey.cielia.lynn@gmail.com
  github : ciel

paginate:         5

production_url : http://[username].github.io

Lanyon :
  version:      2.0.0

  BASE_PATH : "/[repositoryname]"
  ASSET_PATH : "/assets/themes/lanyon"

But even with all of that, it still doesn't work. It does_ work if I type the absolute paths to the files, but that's not how jekyll is supposed to work, from my understanding.


回答1:


To access ASSET_PATH, try :

{{ site.Lanyon.ASSET_PATH }}

Edit : You're using Jekyll Bootstrap (JB) variables, not Jekyll ones.

site.Lanyon.ASSET_PATH is specific to JB. Here it's '/assets/themes/lanyon'

site.Lanyon.BASE_PATH (site.baseurl in Jekyll) is the path from your site root to your Jekyll install.

eg : If you do http://ciel.com/my/jekyll/site/ to reach you site : site.Lanyon.BASE_PATH or site.baseurl = '/my/jekyll/site'

So if you want to reach your assets from any page, you need to do :

<link rel="stylesheet" href="{{ site.Lanyon.BASE_PATH }}{{ site.Lanyon.ASSET_PATH }}/css/poole.css">

or

<link rel="stylesheet" href="{{ site.baseurl }}{{ site.Lanyon.ASSET_PATH }}/css/poole.css">

Et voilà !



来源:https://stackoverflow.com/questions/24813329/cannot-install-lanyon-jekyll-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!