Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@benbalter
Copy link
Contributor

Via github/pages-gem#350 (comment), it's currently not possible to set a baseurl of "" that the Gem respects.

if site.config["baseurl"].to_s.empty? && !["", "/"].include?(repo.baseurl)
makes it look like it should, but it actually does the exact opposite.

The problem is that by default, Jekyll sets the baseurl to "", not nil, meaning there's no way to know if it's a user-supplied value or not.

One option would be to respect site.github.url or site.github.baseurl if passed.

This PR pushes up a failing test and passing tests for the current expected behavior.

If anyone has a better approach, or would like to take a pass at implementing the above, it may be a while before I am able to work on this particular PR.

@parkr
Copy link
Member

parkr commented Jun 14, 2017

The route I'd like to take is to change the default in Jekyll from "" to nil. I think that would clear things up here a lot better. We could backport it to v3.4 and ship it with minimal disruption. Would that be 👍 for you?

parkr added a commit to jekyll/jekyll that referenced this pull request Jun 14, 2017
Using an empty string as the default value causes all sorts of problems
where you don't know if this is user-specified or not. Using an
explicitly "illegal" value, like `nil`, resolves this issue.

See jekyll/github-metadata#97 for more info.
@parkr
Copy link
Member

parkr commented Jun 14, 2017

I have a PR here: jekyll/jekyll#6137

@parkr
Copy link
Member

parkr commented Jun 18, 2017

v3.4.4 is now released with this patch!

let(:user_config) { { "baseurl" => "/" } }

it "mangles site.url" do
expect(site.config["baseurl"]).to eql("/github-metadata")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want this case to mangle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the original logic.

  • Scenario 1: Users incorrectly set their baseurl as /
  • Scenario 2: A sophisticated user is proxying their site and wants their baseurl to be / despite it being a project page

I'd lean towards mangling, as in scenario 1, the user needs our help more than the user in scenario 2.

@benbalter benbalter changed the title WIP: Allow user to set empty baseurl Allow user to set empty baseurl Jul 17, 2017
@benbalter benbalter requested a review from parkr July 17, 2017 15:31
@benbalter
Copy link
Contributor Author

@parkr with 3.4.5 out, I believe this is ready for 👀.

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One test change required, otherwise 👍

Jekyll::Commands::Build.process({
"source" => SOURCE_DIR.to_s,
"destination" => DEST_DIR.to_s,
"gems" => %w(jekyll-github-metadata),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works for Jekyll::VERSION >= 3.5.0.

@benbalter
Copy link
Contributor Author

@jekyllbot: merge

@jekyllbot jekyllbot merged commit 9646d06 into master Jul 17, 2017
@jekyllbot jekyllbot deleted the respect-empty-baseurl branch July 17, 2017 17:07
jekyllbot added a commit that referenced this pull request Jul 17, 2017
@jekyll jekyll locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants