jekyll / minima

Minima is a one-size-fits-all Jekyll theme for writers.
https://jekyll.github.io/minima/
MIT License
3.34k stars 3.55k forks source link
jekyll jekyll-theme jekyll-themes

Disclaimer: The information here may vary depending on the version you're using.
Please refer to the README.md bundled within the theme-gem for information specific to your version or by pointing your browser to the Git tag corresponding to your version. e.g. https://github.com/jekyll/minima/blob/v2.5.0/README.md.
Running bundle show minima will provide you with the local path to your current theme version.

It's Jekyll's default (and first) theme. It's what you get when you run jekyll new.

Theme preview

Installation

Add this line to your Jekyll site's Gemfile:

gem "minima"

And then execute:

$ bundle

Contents At-A-Glance

Minima has been scaffolded by the jekyll new-theme command and therefore has all the necessary files and directories to have a new Jekyll site up and running with zero-configuration.

Layouts

Refers to files within the _layouts directory, that define the markup for your theme.

Base Layout

From Minima v3 onwards, the base layout is named base.html instead of default.html to avoid confusing new users into assuming that name holds special status.

Users migrating from older versions with customized _layouts/default.html are advised to rename their copy to _layouts/base.html. Migrating users with additional customized layouts may either update front matter references to former default.html layout or create a new default.html layout referencing the current base.html, whichever route being the easiest:

---
# new `_layouts/default.html` for backwards-compatibility when multiple
# layouts have been customized.

layout: base
---

{{ content }}

Home Layout

home.html is a flexible HTML layout for the site's landing-page / home-page / index-page.

Main Heading and Content-injection

From Minima v2.2 onwards, the home layout will inject all content from your index.md / index.html before the Posts heading. This will allow you to include non-posts related content to be published on the landing page under a dedicated heading. We recommended that you title this section with a Heading2 (##).

Usually the site.title itself would suffice as the implicit 'main-title' for a landing-page. But, if your landing-page would like a heading to be explicitly displayed, then simply define a title variable in the document's front matter and it will be rendered with an <h1> tag.

Post Listing

This section is optional from Minima v2.2 onwards.
It will be automatically included only when your site contains one or more valid posts or drafts (if the site is configured to show_drafts).

The title for this section is Posts by default and rendered with an <h2> tag. You can customize this heading by defining a list_title variable in the document's front matter.

Includes

Refers to snippets of code within the _includes directory that can be inserted in multiple layouts (and another include-file as well) within the same theme-gem.

Sass

Refers to .scss files within the _sass directory that define the theme's styles.

Refer the skins section for more details.

Assets

Refers to various asset files within the assets directory.

Plugins

Minima comes with jekyll-seo-tag plugin preinstalled to make sure your website gets the most useful meta tags. See usage to know how to set it up.

Usage

Have the following line in your config file:

theme: minima

Customizing templates

To override the default structure and style of minima, simply create the concerned directory at the root of your site, copy the file you wish to customize to that directory, and then edit the file. e.g., to override the _includes/head.html file to specify a custom style path, create an _includes directory, copy _includes/head.html from minima gem folder to <yoursite>/_includes and start editing that file.

The site's default CSS has now moved to a new place within the gem itself, assets/css/style.scss.

In Minima 3.0, if you only need to customize the colors of the theme, refer to the subsequent section on skins. To have your CSS overrides in sync with upstream changes released in future versions, you can collect all your overrides for the Sass variables and mixins inside a sass file placed at _sass/minima/custom-variables.scss and all other overrides inside a sass file placed at path _sass/minima/custom-styles.scss.

You need not maintain entire partial(s) at the site's source just to override a few styles. However, your stylesheet's primary source (assets/css/style.scss) should contain the following:

Therefore, your assets/css/style.scss should contain the following at minimum:

---
---

@import
  "minima/skins/{{ site.minima.skin | default: 'classic' }}",
  "minima/initialize";

Skins

Minima 3.0 supports defining and switching between multiple color-palettes (or skins).

.
├── minima.scss
└── minima
    └── _syntax-highlighting.scss

A skin is a Sass file placed in the directory _sass/minima/skins and it defines the variable defaults related to the "color" aspect of the theme. It also embeds the Sass rules related to syntax-highlighting since that is primarily related to color and has to be adjusted in harmony with the current skin.

The default color palette for Minima is defined within _sass/minima/skins/classic.scss. To switch to another available skin, simply declare it in the site's config file. For example, to activate _sass/minima/skins/dark.scss as the skin, the setting would be:

minima:
  skin: dark

As part of the migration to support skins, some existing Sass variables have been retired and some have been redefined as summarized in the following table:

Minima 2.0 Minima 3.0
$brand-color $link-base-color
$grey-* $brand-*
$orange-color has been removed
Available skins
Skin setting Description
classic Default, light color scheme.
dark Dark variant of the classic skin.
auto Adaptive skin based on the default classic and dark skins.
solarized Adaptive skin for solarized color scheme skins.
solarized-light Light variant of solarized color scheme.
solarized-dark Dark variant of solarized color scheme.

:bulb: Adaptive skins switch between the "light" and "dark" variants based on the user's operating system setting or browser setting (via CSS Media Query prefers-color-scheme).

Customize navigation links

This allows you to set which pages you want to appear in the navigation area and configure order of the links.

For instance, to only link to the about and the portfolio page, add the following to your _config.yml:

header_pages:
  - about.md
  - portfolio.md

Change default date format

You can change the default date format by specifying site.minima.date_format in _config.yml.

# Minima date format
# refer to http://shopify.github.io/liquid/filters/date/ if you want to customize this
minima:
  date_format: "%b %-d, %Y"

Extending the <head />

You can add custom metadata to the <head /> of your layouts by creating a file _includes/custom-head.html in your source directory. For example, to add favicons:

  1. Head over to https://realfavicongenerator.net/ to add your own favicons.
  2. Customize default _includes/custom-head.html in your source directory and insert the given code snippet.

Enabling comments (via Disqus)

Optionally, if you have a Disqus account, you can tell Jekyll to use it to show a comments section below each post.

:warning: url, e.g. https://example.com, must be set in you config file for Disqus to work.

To enable it, after setting the url field, you also need to add the following lines to your Jekyll site:

  disqus:
    shortname: my_disqus_shortname

You can find out more about Disqus' shortnames here.

Comments are enabled by default and will only appear in production, i.e., JEKYLL_ENV=production

If you don't want to display comments for a particular post you can disable them by adding comments: false to that post's YAML Front Matter.

Author Metadata

From Minima-3.0 onwards, site.author is expected to be a mapping of attributes instead of a simple scalar value:

author:
  name: John Smith
  email: "john.smith@foobar.com"

To migrate existing metadata, update your config file and any reference to the object in your layouts and includes as summarized below:

Minima 2.x Minima 3.0
site.author site.author.name
site.email site.author.email

Social networks

You can add links to the accounts you have on other sites, with respective icon as an SVG graphic, via the config file. From Minima-3.0 onwards, the social media data is sourced from config key minima.social_links. It is a list of key-value pairs, each entry corresponding to a link rendered in the footer. For example, to render links to Jekyll GitHub repository and Twitter account, one should have:

minima:
  social_links:
    - { platform: github,  user_url: "https://github.com/jekyll/jekyll" }
    - { platform: twitter, user_url: "https://twitter.com/jekyllrb" }

Apart from the necessary keys illustrated above, title may also be defined to render a custom link-title. By default, the title is the same as platform. The platform key corresponds to the SVG id of the sprite in the composite file at URL /assets/minima-social-icons.svg.

The theme ships with an icon for rss and icons of select social-media platforms:

To render a link to a platform not listed above, one should first create a file at path _includes/social-icons/<PLATFORM>.svg comprised of graphic markup without the top-level <svg></svg>. The icon is expected to be centered within a viewbox of "0 0 16 16". Then, make an entry under key minima.social_links.

For example, to render a link to an account of user john.doe at platform deviantart.com, the steps to follow would be:

Notes:

Enabling Google Analytics

To enable Google Analytics, add the following lines to your Jekyll site:

  google_analytics: UA-NNNNNNNN-N

Google Analytics will only appear in production, i.e., JEKYLL_ENV=production

Enabling Excerpts on the Home Page

To display post-excerpts on the Home Page, simply add the following to your _config.yml:

show_excerpts: true

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jekyll/minima. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Development

To set up your environment to develop this theme, run script/bootstrap.

To test your theme, run script/server (or bundle exec jekyll serve) and open your browser at http://localhost:4000. This starts a Jekyll server using your theme and the contents. As you make modifications, your site will regenerate and you should see the changes in the browser after a refresh.

License

The theme is available as open source under the terms of the MIT License.