New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

absolute_url vs relative_url #1588

Closed
mplacona opened this Issue Mar 17, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@mplacona

mplacona commented Mar 17, 2018

  • This is a question about using the theme.
  • This is a feature request or enhancement.
  • I believe this to be a bug with the theme.
    • I am using the latest version of the theme.
    • I have updated all gems with bundle update.
    • I have tested locally with bundle exec jekyll build.

Environment information

  • **Minimal Mistakes version:latest
  • **Jekyll version:3.7.3

Expected behaviour

Seems like this theme uses absolute_url, which will yield urls like 0.0.0.0:PORT when you use it with docker. I've noticed that your other theme "so-simple" works well with docker as it uses relative_url. I was wondering if there's a reason for that. I'd be happy to update it all and send you a PR, but wanted to check with you first if there's a reason. Should all work the same after the update.

@mmistakes

This comment has been minimized.

Owner

mmistakes commented Mar 17, 2018

Are you correctly assigning JEKYLL_ENV=production at build? Jekyll defaults development, which overrides url with localhost... or in your case 0.0.0.0:PORT.

Give production a try first. absolute_url could likely be changed to relative_url, but I think your issue is the environment flag. You might want to search through the closed issues as I know I've seen others who had the same problem and solved it without messing with the theme.

@mmistakes

This comment has been minimized.

Owner

mmistakes commented Mar 17, 2018

Here's how to solve it. Closing as this is a duplicate.

#1162 (comment)

@mplacona

This comment has been minimized.

mplacona commented Mar 17, 2018

Thanks @mmistakes. I'd already tried that, but it doesn't quite solve the problem. When you set the build for production, you're basically saying "use the url as it is in my _config.xml". In the example you gave me, the author changes the url to be what they want locally. However, deploying this to production would mean changing that again, which is prone to errors.

Ideally, if you use a relative path instead, the url stops getting on the way.

@mmistakes

This comment has been minimized.

Owner

mmistakes commented Mar 17, 2018

This is where multiple config files can come into place. You can daisy chain them in your build command.

Specify config files instead of using _config.yml automatically. Settings in later files override settings in earlier files.

ref: https://jekyllrb.com/docs/configuration/

# _config.yml
# contains all your normal configs
# _config.dev.yml (or whatever you want to name it)
# add any variables you want to override for development purposes

url: http://localhost:4000

Then your Jekyll build command would change to jekyll serve --config _config.yml,_config.dev.yml

@mplacona

This comment has been minimized.

mplacona commented Mar 17, 2018

Right on! Doing that solved it.

Still think it would be easier to just use relative urls to avoid the "hackery" around how you start Jekyll, but this completely solved it.

Thank you for the responsiveness!

mmistakes added a commit that referenced this issue Mar 20, 2018

Replace `absolute_url` with `relative_url`
Where it makes sense replace asset paths and navigation related paths with `relative_url` filter.

Leave SEO related `<head>` elements and social sharing links as `absolute_url`.

Fixes #1588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment