jekyll / jekyll-help

NO LONGER MAINTAINED. USE JEKYLL TALK INSTEAD.
https://talk.jekyllrb.com
146 stars 19 forks source link

URLs not being properly formatted - contain commas #227

Closed sr-murthy closed 9 years ago

sr-murthy commented 9 years ago

Hi

I have two questions (I have checked the docs and other issues but cannot find a solution to this).

  1. I have created separate layout files (in _layouts/) for a default site-wide page style, and non-discussion posts and discussion posts (posts with Disqus comments enabled). Specifically, pages follow the default layout specified in default.html which is standard, and non-discussion posts follow the standard post.html layout. But the discussion_posts style were defined in _config.yml in the following way:
    defaults:  
    -
      scope:
        path: "/_posts/"
        type: "posts"
      values:
        layout: "discussion_posts"
        author: "Sandeep Murthy"
    -    
      scope:
        path: "."
        type: "pages"
      values:
        layout: "default"
        author: "Sandeep Murthy"

I'm not quite clear about the path key? I am trying to specify a relative path (relative to the root of the repo) but I am not quite clear if this is causing my problem. This may be linked to how the URLs are appearing incorrectly. For example, my index.html contains a list of posts, this is generated by liquid code which loops over site.posts. The code is

<ul class="post-list">
   {% for post in site.posts %}
     <li>
       <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>

       <h2>
         <a class="post-link" href="{{ site.url }}/{{ post.url }}"#disqus_thread>{{ post.title }}</a>
       </h2>
     </li>
   {% endfor %}
 </ul>

The site.url is set to http://localhost:4000 in _config.yml when I'm testing the site locally. This code displays the posts (there is only one right now) as

http://localhost:4000//blog,/first/post,/jekyll,/codefree,/2015/2015/01/01/first-post.html

The post name is 2015-01-01-first-post.md, which exists in the root of the repo, and as you can see above, there are commas separating them.

Why is this happening? Is there a simpler way of outputting the URLs? Thanks in advance.

troyswanson commented 9 years ago

This is some pretty strange behavior that can probably be explained by a wayward bit of code somewhere. Would it be possible for you to post a link to the repo that this site uses?

sr-murthy commented 9 years ago

Yes, https://github.com/sr-murthy/sr-murthy.github.io.

sr-murthy commented 9 years ago

I should add that I am fairly new to liquid, YAML (and jekyll) and this line is perhaps the problem:

<a class="post-link" href="{{ site.url }}/{{ post.url }}"#disqus_thread>{{ post.title }}</a>

What should post.url look like - it's not what I'm expecting, but this line is standard in index.html when you start a jekyll site. It would be helpful if jekyll docs define the full list of attributes of post and all other variables this page.

sr-murthy commented 9 years ago

Fixed.

troyswanson commented 9 years ago

Can you post the fix that you found so that others with a similar problem can reference? Sorry I wasn't able to dig deeper into your issue to help, by the way. Been really busy :confounded:

sr-murthy commented 9 years ago

Hi

it's not quite fixed actually, but there's a related problem with permalinks which is the real problem - that.

Sandeep.

parkr commented 9 years ago

This repository is no longer maintained. If you're still experiencing this problem, please search for your issue on Jekyll Talk, our new community forum. If it isn't there, feel free to post to the Help category and someone will assist you. Thanks!