集合页面不继承默认样式

时间:2015-03-02 00:59:09

标签: jekyll

问题:我为我的Jekyll网站设置了一个名为项目的集合。它会在 portfolio.html 上输出页面。各个项目存储在 _projects 中,并继承 portfolio_piece.html 布局样式。该portfolio_piece.html假设具有 default.html 布局样式,但它不起作用。当我尝试手动将我需要的代码添加到portfolio_piece.html时,它也不起作用。它们都只会导致带有必要内容的无格式页面。难道我做错了什么?

Config.yml

# projects
collections:
  projects:
    output: true

portfolio.html

{% for each in site.projects %}
<div class="six columns">
    <a href="{{ each.url }}" title="{{ each.title }}"><img src="{{ each.image_thumb }}" alt="{{ projects.title }}"></a>
        <h4>{{ each.title }}</h4>
        <p><span class="desc project">{{ each.description }}</span></p>
</div>
{% endfor %}

_projects / project.md

---
layout: portfolio_piece
image_thumb: http://placehold.it/350x250
image_full: http://placehold.it/600x300
title: Toei Channel
description: Branding / Design / Development
---

_layouts / portfolio_piece.html

---
layout: default
---

   <div class="row"> 

<a href="#" title="{{ page.title }}">
    <img src="{{ page.image_full }}" alt="{{ page.title }}">
</a>
<h4>{{ page.title }}</h4>
<p>
    <span class="desc project">{{ page.description }}</span>
</p>
</div>

_layouts / default.html中

&#13;
&#13;
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>{% if site.title %} {{ site.title }} {% endif %}</title>
  <meta name="description" content="{% if site.description %} {{ site.description }} {% endif %}">
  <meta name="author" content="{% if site.author %} {{ site.author }} {% endif %}">
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- fonts -->
  <link href="//fonts.googleapis.com/css?family=Raleway:200,300,400,600" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Merriweather:300" rel="stylesheet" type="text/css">
    <!-- css -->
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/skeleton.css">
    <link rel="stylesheet" href="css/style.css">
    <!-- favicon -->
  <link rel="icon" type="image/png" href="images/favicon.png">

</head>
<body>
    
  <div class="container">
      
      {{ content }}

    </div> <!-- end .container -->

    <!-- external scripts -->
    <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="js/scripts.js"></script>
</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

如果您的网站位于您网域的根目录(http://yourdoamin.tld),则可以按以下方式调用您的资源:

<link rel="stylesheet" href="/css/normalize.css">
<script src="/js/scripts.js"></script>
<img src="/path/to/img/toto.jpg">

如果您的网站 位于您网域的根目录(http://yourdoamin.tld/somefolder),

_config.yml设置baseurl/somefolderbaseurl: somefolder

像这样调用你的资源:

<link rel="stylesheet" href="{{ site.baseurl }}/css/normalize.css">
<script src="{{ site.baseurl }}/js/scripts.js"></script>
<img src="{{ site.baseurl }}/path/to/img/toto.jpg">