Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Page url always returning a root-based url #857

Closed
jimi-c opened this Issue · 10 comments

3 participants

@jimi-c

Trying to track down a weird issue, where in safe mode the directory of pages is always set to '/'. I have traced this to the page.url accessor, which always seems to be returning a URL that is located in the root but does not include the sub-directory. This causes problems with the pagination generator when the _posts are not located in the root.

First, I added some debugging puts in the code, and saw this:

DEBUG: in site render(): page.dir=, page.name=index.md
DEBUG: in page.url(): self.url=/index.html
DEBUG: in site render(): page.dir=/posts/page2, page.name=index.html
DEBUG: in page.url(): self.url=/index.html
DEBUG: in site render(): page.dir=/posts/page3, page.name=index.html
DEBUG: in page.url(): self.url=/index.html

This shows the page.url returning the URLs incorrectly. The puts is the first line in the def, so @url is apparently always set, so none of the rest of the code in the function is being used apparently.

I haven't tracked down why, but when in --safe mode, the page.dir accessor is hit (but not when safe=false), so the code there always returns the basedir of the url, which is always '/'. This is what makes the pagination plugin fail, since I don't have an index.html in my root:

DEBUG: in page initialize: base=/root/devel/new_cobbler.github.com, dir=/, name=index.html
/usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/convertible.rb:28:in `read': No such file or directory - /root/devel/new_cobbler.github.com/index.html (Errno::ENOENT)
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/convertible.rb:28:in `read_yaml'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/page.rb:25:in `initialize'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/generators/pagination.rb:40:in `new'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/generators/pagination.rb:40:in `block in paginate'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/generators/pagination.rb:36:in `each'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/generators/pagination.rb:36:in `paginate'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/generators/pagination.rb:15:in `block in generate'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/generators/pagination.rb:13:in `each'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/generators/pagination.rb:13:in `generate'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/site.rb:190:in `block in generate'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/site.rb:189:in `each'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/site.rb:189:in `generate'
    from /usr/local/share/gems/gems/jekyll-0.12.1/lib/jekyll/site.rb:40:in `process'
    from /usr/local/share/gems/gems/jekyll-0.12.1/bin/jekyll:264:in `'
    from /usr/local/bin/jekyll:23:in `load'
    from /usr/local/bin/jekyll:23:in `'

If I modify page.dir to return @dir instead of the ternary operator that's there now everything works fine.

I haven't tracked down exactly why page.dir is accessed only when safe=true, but this is definitely the reason it fails. Is there any reason why the page.dir accessor just can't return @dir if it's set?

@parkr
Owner

is this on the current master or an old version? i just accepted a pr that tackled this

@jimi-c

This is on v0.12.1, the most recent gem available. If this is redundant and someone else fixed it then feel free to close it. The only other question I'd have is if you knew when would the next release be, and when github might start using it? This bug is preventing me from pushing up my most recent site update.

@parkr
Owner

Releasing at the end of the month sometime, no idea when GitHub will be using it. Probably soon thereafter!

@jimi-c

I did try building master, and I'm still having the issue. Which PR was the one you merged?

@parkr
Owner

I think #536 did the trick. Please install version 1.0.0.beta1 for me and test it out!

gem install jekyll --pre

Notably, --auto has changed to --watch and we use subcommands build and serve.

@jwebcat
@jimi-c

It does appear to work, though I did get one other error on the "exclude" line in my _config.yml - I'll chalk that up to it being a beta version. Here's the error if you're interested:

$ jekyll build
Configuration file: /root/devel/new_cobbler.github.com/_config.yml
            Source: /root/devel/new_cobbler.github.com
       Destination: ./_site
      Generating... error: undefined method `glob_include?' for "readme.md test.idx":String. Use --trace to view backtrace

$ grep exclude _config.yml 
exclude: readme.md test.idx

That test.idx is generated by a plugin I wrote, so when I use --safe it works fine.

@parkr
Owner

Your exclude has to be an array! Does it work with:

exclude: ['readme.md', 'test.idx']
@jimi-c

Yep that works. Is there documentation on the differences that are going to be in 1.0?

@parkr
Owner

We're going to launch a new jekyllrb.com with updated (and beautiful) docs on the new features. The History.txt file gives us a detailed look at what changes were made, and I'll probably post some sort of blog post about the new stuff. :-)

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.