问题
I am a first time jekyll
and ruby
user - 0 experience in either of them. I am tackling them because quite frankly, I just want to.
I'm posting my actual question up top, since this is a lot to read. All details are included below though;
ACTUAL QUESTION
- What is happening here?
- How can I reproduce this for my Lanyon theme so I don't need the fully qualified name?
- How can I get the
BASE_PATH
andASSET_PATH
merged in my Lanyon theme as well?
DETAILS
I've followed all of the instructions here; jekyll quick start guide
and for the most part I'm not as lost as I thought I would be. But that's where it ends. I'm having a very big amount of disparity between a few things, not the least of which is how these global variables
work. I am referring to BASE_PATH
and ASSET_PATH
.
If you look in the _config.yml
file of jekyll-bootstrap
, the general structure would look like this, with comments removed;
JB: version: 0.3.0 BASE_PATH: false ASSET_PATH: false
Ok, so they say to replace those values with information relative to your site. This is where I'm getting tripped up.
If I download a different jekyll theme, this looks a bit different. I cite another post I made on stackoverflow regarding Lanyon, which has neither the base or asset path in it. Still I've checked in on other themes and some have it, some do not, but the consistency is not there.
If you continue to explore the
jekyll-bootstrap
theme, you can find a peculiar file in_includes/JB/
calledsetup
. The contents of this file are as follows;
{% capture jbcache %} <!-- - Dynamically set liquid variables for working with URLs/paths --> {% if site.JB.setup.provider == "custom" %} {% include custom/setup %} {% else %} {% if site.safe and site.JB.BASE_PATH and site.JB.BASE_PATH != '' %} {% assign BASE_PATH = site.JB.BASE_PATH %} {% assign HOME_PATH = site.JB.BASE_PATH %} {% else %} {% assign BASE_PATH = nil %} {% assign HOME_PATH = "/" %} {% endif %} {% if site.JB.ASSET_PATH %} {% assign ASSET_PATH = site.JB.ASSET_PATH %} {% else %} {% capture ASSET_PATH %}{{ BASE_PATH }}/assets/themes/{{ page.theme.name }}{% endcapture %} {% endif %} {% endif %} {% endcapture %}{% assign jbcache = nil %}
Now please remember, I have zero experience in this language, so I am going on pure, 100% speculation, but it looks to me like this is doing some kind of merging between BASE_PATH
and ASSET_PATH
to make ASSET_PATH
one and the same plus extras. If I am correct, this would mean that if you had ..
`BASE_PATH: "/myblog"` `ASSET_PATH: "/assets"`
And then you tried to call upon this ..
<link rel="stylesheet" href="{{ ASSET_PATH }}/css/site.css" />
You would get the right path, which is /assets/themes/bootstrap-3/bootstrap/css/site.css
,
or in the case of another theme, like my lanyon
one, /assets/themes/lanyon/css/site.css
.
This seems like the expected behavior, but it's that setup
file that is confusing me, and twisting things around.
Pursuant another topic on stackoverflow; I was told that I should instead call the ASSET_PATH
with a qualifier to its theme, like this;
{{ site.Lanyon.ASSET_PATH }}
.
Or, in the case of the original bootstrap
theme, I suppose it would be ...
{{ site.JB.ASSET_PATH }}
Now we go back to the setup
file; in the jekyll-bootstrap
theme, we can go to _layouts/page.html
and we see quite clearly that setup
file utilized like this..
{% include JB/setup %}
回答1:
What is happening here?
JB/setup just calculate BASE_PATH, HOME_PATH and ASSET_PATH depending on your setup in site.JB global vars. Those are shortcuts that you will use in you templates.
How can I reproduce this for my Lanyon theme so I don't need the fully qualified name?
How can I get the BASE_PATH and ASSET_PATH merged in my Lanyon theme as well?
As Lanyon is made to run with the base Jekyll and not Jekyll Bootstrap, it needs some integration in order to work as a theme. The Jekyll Bootstrap Theme API explains the process.
As it is a little touchy, I've put and example integration in my Github. First commits is JB base and last commit is Lanyon integration.
来源:https://stackoverflow.com/questions/24827657/first-time-jekyll-users-difficulty-understanding-bootstrap-theme