第一次"jekyll"用户-难以理解"bootstrap"主题 [英] first time 'jekyll' users - difficulty understanding 'bootstrap' theme

查看:99
本文介绍了第一次"jekyll"用户-难以理解"bootstrap"主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次使用jekyllruby用户-他们两个都经历了0.我要解决这些问题,因为坦率地说,我只是想这么做.

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;

  1. 这是怎么回事?
  2. 如何为我的 Lanyon 主题重现此名称,所以我不需要完全限定的名称?
  3. 如何将BASE_PATHASSET_PATH合并到我的 Lanyon 主题中?
  1. What is happening here?
  2. How can I reproduce this for my Lanyon theme so I don't need the fully qualified name?
  3. How can I get the BASE_PATH and ASSET_PATH merged in my Lanyon theme as well?

详细信息

我已按照此处的所有说明进行操作; jekyll快速入门指南

DETAILS

I've followed all of the instructions here; jekyll quick start guide

在大多数情况下,我并没有像我想象的那样迷路.但这就是结束的地方.我在几件事之间有很大的差距,其中最重要的是这些 global variables 的工作方式.我指的是 BASE_PATH ASSET_PATH .

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.

如果您查看jekyll-bootstrap_config.yml文件,则一般结构如下所示,其中删除了注释;

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.

  1. 如果我下载不同 jekyll主题,则外观会有所不同.我引用了我在stackoverflow上发表的关于 Lanyon 的另一篇文章,其中没有基础路径或资产路径.我仍然检查了其他主题,有一些主题,有的没有,但是一致性不高.

  1. 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.

如果继续探索jekyll-bootstrap主题,则可以在_includes/JB/中找到一个名为setup的特殊文件.该文件的内容如下;

If you continue to explore the jekyll-bootstrap theme, you can find a peculiar file in _includes/JB/ called setup. 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 %}

现在,请记住,我对这种语言的了解为零,所以我会进行纯粹的100%的猜测,但是它对我的印象看起来 BASE_PATH ASSET_PATH 之间的一种合并,使ASSET_PATH成为一个相同且附加的内容.如果我是正确的话,那就意味着如果你有..

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" />

您将获得正确的路径,即/assets/themes/bootstrap-3/bootstrap/css/site.css, 或其他主题,例如我的lanyon主题/assets/themes/lanyon/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.

这似乎是预期的行为,但正是setup文件使我感到困惑,并使事情变得混乱.

This seems like the expected behavior, but it's that setup file that is confusing me, and twisting things around.

追求 关于stackoverflow的另一个主题 ;有人告诉我,我应该像这样用主题的限定词来调用ASSET_PATH

{{ site.Lanyon.ASSET_PATH }}.

或者,对于原始的bootstrap主题,我想它应该是...

Or, in the case of the original bootstrap theme, I suppose it would be ...

{{ site.JB.ASSET_PATH }}

现在,我们回到setup文件;在jekyll-bootstrap主题中,我们可以转到_layouts/page.html,我们可以很清楚地看到setup文件是这样使用的.

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 %}

推荐答案

这是怎么回事?

JB/设置仅根据您在site.JB全局变量中的设置来计算BASE_PATH,HOME_PATH和ASSET_PATH.这些是您将在模板中使用的快捷方式.

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.

如何为我的Lanyon主题重现此名称,所以我不需要完全限定的名称?

如何将BASE_PATH和ASSET_PATH合并到我的Lanyon主题中?

由于Lanyon是与基本的Jekyll一起运行的,而不是与Jekyll Bootstrap一起运行的,因此它需要进行一些集成才能用作主题. Jekyll Bootstrap主题API 解释了该过程.

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.

由于有点麻烦,我在Github中放置了示例集成.第一次提交是基于JB的,最后一次提交是Lanyon集成.

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.

这篇关于第一次"jekyll"用户-难以理解"bootstrap"主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆