Minimal-mistakes: Question: Use with GH pages without requiring fork?

Created on 19 Nov 2016  路  13Comments  路  Source: mmistakes/minimal-mistakes

  • [x] This is a question about using the theme.

Environment informations

  • Operating system: macOS / OS X

Expected behavior

I would like to be able to use this theme with GH pages, but don't want to fork it in the event that the repository need to use a different theme in the future without having to switch to a different repository for the page (if that makes sense), which would confuse people. Is this possible atm?

Support

All 13 comments

It's possible but would require you change up your workflow. What you'll want to do is install the theme as a gem. Check the docs for instructions on that.

The problem is GitHub Pages doesn't currently support 3rd party theme gems. Similar to how they don't allow Jekyll plugins (except for a few that have been whitelisted). So instead of pushing commits to GH and having it build your site, you need to build it locally and push the contents of your _site folder.

It's not as nice of a workflow but sadly that's the only way if you want to use a theme gem vs. forking a theme. If you Google around you can find some variations on this process. A lot of people use CI services like Travis to build their site and deploy to GH.

The repository can be forked, pulled locally, removed from github, recreated as an empty repo, then pushed to for this effect, without needing any _site folder. Ensure you have pages enabled for the branch in the repo settings.

Example of this in use: https://github.com/Plailect/Guide

@Plailect - thanks that's very helpful! 馃懇馃徎馃憤

@Plailect : and how do you update the theme from there please ?
Im in the same situtaion, i forked and created a new repo, but my mm theme version is still 3.x and i'd like to update to the latest one 4.x

https://mmistakes.github.io/minimal-mistakes/docs/upgrading/

With "Git" or "Update Files Manually"

I tried to use the gem version with GitHub Pages and travis, but I'm having some problems.
Here is my repository, I'm able to build it with success.
https://github.com/4brunu/4brunu.github.io

But when I try to access my site, the css and other resources are not being loaded...
https://4brunu.github.io/
https://4brunu.github.io/about
https://4brunu.github.io/blog/2017/01/18/welcome-to-jekyll

Any suggestions?
Am I doing something wrong?

@4brunu Your post/page are missing the layout in its YAML Front Matter. Either add layout: single to it or setup front matter defaults for all your posts in _config.yml.

https://jekyllrb.com/docs/configuration/#front-matter-defaults

@4brunu Not sure. Something is overriding it then. If you look at the compiled HTML for the posts/pages they definitely don't have the full layout. Jekyll is just converting the .md files and has none of the layout applied.

That's why there is no CSS.

For example this post (https://4brunu.github.io/blog/2017/01/18/welcome-to-jekyll)

Just has the actual content in the HTML... it's not wrapped with any of the layout. Maybe something is screwy with how you have Travis CI setup or Jekyll in general. Pretty sure it has nothing to do with the theme. Does it build locally?

<p>You鈥檒l find this post in your <code class="highlighter-rouge">_posts</code> directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run <code class="highlighter-rouge">jekyll serve</code>, which launches a web server and auto-regenerates your site when a file is updated.</p>

<p>To add new posts, simply add a file in the <code class="highlighter-rouge">_posts</code> directory that follows the convention <code class="highlighter-rouge">YYYY-MM-DD-name-of-post.ext</code> and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.</p>

<p>Jekyll also offers powerful support for code snippets:</p>

<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">def</span> <span class="nf">print_hi</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span>
  <span class="nb">puts</span> <span class="s2">"Hi, </span><span class="si">#{</span><span class="nb">name</span><span class="si">}</span><span class="s2">"</span>
<span class="k">end</span>
<span class="n">print_hi</span><span class="p">(</span><span class="s1">'Tom'</span><span class="p">)</span>
<span class="c1">#=&gt; prints 'Hi, Tom' to STDOUT.</span></code></pre></figure>

<p>Check out the <a href="http://jekyllrb.com/docs/home">Jekyll docs</a> for more info on how to get the most out of Jekyll. File all bugs/feature requests at <a href="https://github.com/jekyll/jekyll">Jekyll鈥檚 GitHub repo</a>. If you have questions, you can ask them on <a href="https://talk.jekyllrb.com/">Jekyll Talk</a>.</p>

@4brunu I just cloned your repo and tried to build it locally. It worked, so the issue isn't Jekyll or theme. As a comparison here is the HTML I'm getting for your welcome-to-jekyll post.

I don't know enough about the Rake task your using to deploy with Travis CI. Maybe that's the culprit. As bundle exec jekyll build works as expected.

@mmistakes But even the home page, that has the compiled HTML is not working :/
https://github.com/4brunu/4brunu.github.io/blob/gh-pages/index.html

@4brunu That's a path thing. If you look at the HTML source the CSS is being referenced here https://4brunu.github.io/assets/css/main.css which doesn't exist. It's in your gh-pages branch but as far as I can tell it's not pushed to 4bruno.github.io yet. I'm sure that has to do with your Rake task and Travis CI deployment script.

Like I mentioned earlier I don't know Travis all that well. That and your deployment process is the issue. Don't have enough experience with either to offer any other suggestions.

@mmistakes your last message gave me a hint, I found the solution and I'm leaving it here, because it could help anyone.
The problem is that in the repository settings, Github Pages section, I found this

screen shot 2017-01-19 at 15 53 42

My repository structure was, the source code was in master branch and the generated source was in gh-pages branch.
But my page was pointing to the master branch.
So I move the source code to the source branch and the generated source to my master branch.
And now I got everything working :)
Thanks for the help.

Was this page helpful?
0 / 5 - 0 ratings