2014-06-17 2 views
4

, 나는 내가 {{site.collections을}} 인쇄 할 때, 출력이 "popular_posts"입니다 _config.ymlJekyll에서 사용자 정의 모음을 정의하는 방법은 무엇입니까? <a href="http://jekyllrb.com/docs/collections/#documents" rel="nofollow">Jekyll Collections documentation</a> 다음

_config.yml 

collections: 
- popular_posts 

에 다음 코드를 썼다.

"_popular_posts"라는 폴더를 "_posts"와 같은 수준으로 만들었습니다. _popular_posts에는 게시물과 동일한 YAML 앞부분이 포함 된 두 개의 .md 파일이 들어 있습니다.

그러나 {{site.popular_posts}} 또는 {{site.collections.popular_posts}}를 출력해도 출력되지 않습니다.

다음 코드가 작동하도록 Jekyll이 해당 디렉토리의 .md 파일을 인식하도록하려면 어떻게해야합니까?

{% for popular_post in site.popular_posts %} 
    <a href="{{ popular_post.link }}"> 
    <h1>{{ popular_post.title }}</h1> 
    <img class="pop-img" src="{{ popular_post.image_url }}"> 
    </a> 
    <span id="pop-order"><span class="pop-current-popular_post-number">{{ popular_post.number }}</span>/5</span> 
{% endfor %} 
+0

'output :'을'true'로 설정 했습니까? 필자는 수집 물을 완전히 이해하지는 못한다.하지만 필자가 이해할 때, 그것은 지킬이 수집 항목을 생성하도록 요구한다. 또한 콜렉션 기능은 베타 버전으로되어 있으며 아직 완전히 기능하지 않을 수 있습니다. –

답변

4

매우 간단합니다. 너는 바른 길을 가고있다. 당신의 _config.yml에서 :

collections: 
- popular_posts 

_popular_posts의 모든 파일에 읽기 지킬 말할 것이다.

당신이 (지금은 어떻게 _posts 작품 등) 해당 출력 파일을 가지고이 두 파일의 각을 원하는 경우에, 당신은 당신의 _config.yml에 변경할 수 있습니다 : 이것은 /popular_posts/filename1.html에서 파일을 생성합니다

collections: 
    popular_posts: 
    output: true 

/popular_posts/filename2.html, 각 게시물마다 한 페이지

모음집은 only recently up on GitHub Pages입니다. 그래서 거기에서이 작업을 시도했다면 실패했을 것입니다.

필요한 경우 도움을 더 받으려면 jekyll-help을 확인하십시오!