mmistakes / minimal-mistakes

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
https://mmistakes.github.io/minimal-mistakes/
MIT License
12.24k stars 25.35k forks source link

[QUESTION] Which is the best way to easily switch between compiling locally and pushing to githug-pages? #1732

Closed vncoelho closed 6 years ago

vncoelho commented 6 years ago

Hi, guys.

First of all, congrulations for this great template. I am wondered about the possibilities that ideas like Jekyll are promoting.

What is the best way to switch between local tests and github. Because if I run remote_theme locally I will problems with 'bundle update & bundle exec jekyll serve`

In this sense, I am constantly commenting and uncommenting the gemfile and config.

source "https://rubygems.org"

# Remove comments local tests
# gem "jekyll", "~> 3.5"
# gem "minimal-mistakes-jekyll"

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-paginate"
  gem "jekyll-sitemap"
  gem "jekyll-gist"
  gem "jekyll-feed"
  gem "jemoji"
  gem "jekyll-algolia"
end

# Remove comments for github-pages
/#
gem "github-pages", group: :jekyll_plugins
gem "tzinfo-data"
gem "wdm", "~> 0.1.0" if Gem.win_platform?
/#

And switching from remote to theme:

remote_theme             : "mmistakes/minimal-mistakes"
#theme           : "minimal-mistakes-jekyll"
vncoelho commented 6 years ago

I am now using the following script:

#!/bin/bash
echo "Starting bundle jekyll serve"
cp _config.yml ./_config-temp.yml
sed -i '/remote_theme/c\theme            : "minimal-mistakes-jekyll"' ./_config-temp.yml
bundle exec jekyll serve --config ./_config-temp.yml

Furthermore, I am ignoring the Gemfile since github is being able to generate the page without it.

Is it correct?

mmistakes commented 6 years ago

If you want to test locally and host with GitHub Pages, then the preferred method is using remote_theme. You'll also want to setup your Gemfile to use gem "github-pages" as it will mimic the same version of Jekyll and plugins they use.

There's no reason why you should need to switch between remote_theme and theme. Stick with just remote_theme and keep your Gemfile like this:

source "https://rubygems.org"

gem "github-pages", group: :jekyll_plugins

Refer to GitHub's docs on how to set this up if you need further help.

There's no reason you'd need to run bundle update other than to update the github-pages gem and it's dependencies. When you use the theme as a remote you don't update the theme as there is no gem to update.

The way that works is anytime you build the site it pulls down whatever version of the theme exists on the master branch. So in theory you should always have the latest version when building with nothing to do by you.

If you're having issues running bundle exec jekyll serve locally then something is up with your environment and the github-pages gem... not the theme.

vncoelho commented 6 years ago

Hey, @mmistakes, thanks very much for this dip attention.

I tried the command with build but later I saw that you edited it. The command serve worked but took a little bit more time to get the server up on port 4000 (around 35-40s compared to couple of seconds when running gem and theme locally). Anyway. It was a good workaround for running it locally without any modification. Thank you very much.

Just one last question. I check some other command on the guidelines, such as rake preview. Should I use it for something, as well as that build you mentioned first?

Best regards,

vncoelho commented 6 years ago

Now I noticed that it only worked locally when I added github: [metadata] to the _config.yml

mmistakes commented 6 years ago

rake preview is a development thing. It's used when adding new features and uses the source files in /example to spin up jekyll serve.

Jekyll's Minima theme did it first... that's where I got the idea.

And yes, remote theme will be slightly slower as it has to downloaded the theme every time it builds. There was some discussion about caching between builds, so maybe take a look at that project if you have feedback to add.

Closing as these concerns are all Jekyll (and it's dependencies) related... nothing specific here to the theme.