Skip to content
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
4 of 6 tasks
mplacona opened this issue Mar 17, 2018 · 5 comments
Closed
4 of 6 tasks

absolute_url vs relative_url #1588

mplacona opened this issue Mar 17, 2018 · 5 comments

Comments

@mplacona
Copy link

  • 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
Copy link
Owner

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
Copy link
Owner

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

#1162 (comment)

@mplacona
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
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
kkunapuli pushed a commit to kkunapuli/kkunapuli.github.io that referenced this issue May 30, 2019
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 mmistakes#1588
sumeetmondal pushed a commit to sumeetmondal/sumeetmondal.github.io that referenced this issue Sep 10, 2019
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 mmistakes#1588
jchwenger pushed a commit to jchwenger/jchwenger.github.io that referenced this issue May 5, 2023
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 mmistakes#1588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants