--- title: "Layouts" permalink: /docs/layouts/ excerpt: "Descriptions and samples of all layouts included with the theme and how to best use them." single_layout_gallery: - image_path: /assets/images/mm-layout-single-header.png alt: "single layout with header example" - image_path: /assets/images/mm-layout-single-meta.png alt: "single layout with comments and related posts" modified: 2016-10-06T23:02:37-04:00 --- {% include toc icon="columns" title="Included Layouts" %} The bread and butter of any theme. Below you'll find the layouts included with Minimal Mistakes, what they look like and the type of content they've been built for. ## Default Layout The base layout all other layouts inherit from. There's not much to this layout apart from pulling in several `_includes`: * `` elements * masthead navigation links * {% raw %}`{{ content }}`{% endraw %} * page footer * scripts **Note:** You won't ever assign this layout directly to a post or page. Instead all other layouts will build off of it by setting `layout: default` in their YAML Front Matter. {: .notice--warning} ### Layout Based and User-Defined Classes Class names corresponding to each layout are automatically added to the `` element eg. ``. | layout | class name | | ---------------- | --------------------------- | | archive | `.layout--archive` | | archive-taxonomy | `.layout--archive-taxonomy` | | single | `.layout--single` | | splash | `.layout--splash` | | home | `.layout--home` | Using YAML Front Matter you can also assign custom classes to target with CSS or JavaScript. Perfect for "art directed" posts or adding custom styles to specific pages. Example: ```yaml --- layout: splash classes: - landing - dark-theme --- ``` Outputs: ```html ``` ## Compress Layout A Jekyll layout that compresses HTML in pure Liquid. To enable add `layout: compress` to `_layouts/default.html`. **Note:** Has been known to mangle markup and break JavaScript... especially if inline `// comments` are present. For this reason it has been disabled by default. {: .notice--danger} * [Documentation](http://jch.penibelst.de/) ## Single Layout The layout you'll likely use the most --- sidebar and main content combo. **Includes:** * Optional header image with caption * Optional header overlay (solid color/image) + text and optional "call to action" button * Optional social sharing links module * Optional comments module * Optional related posts module {% include gallery id="single_layout_gallery" caption="Image header and meta info examples for `single` layout" %} Assign with `layout: single`, or better yet apply as a [Front Matter default]({{ "/docs/configuration/#front-matter-defaults" | absolute_url }}) in `_config.yml`. ## Archive Layout Essentially the same as `single` with markup adjustments and some modules removed. **Includes:** * Optional header image with caption * Optional header overlay (solid color/image) + text and optional "call to action" button * List and grid views
archive layout example
List view example.
Below are sample archive pages you can easily drop into your project, taking care to rename `permalink`, `title`, or the filename to fit your site. Each is 100% compatible with GitHub Pages. * [All Posts Grouped by Category -- List View][posts-categories] * [All Posts Grouped by Tags -- List View][posts-tags] * [All Posts Grouped by Year -- List View][posts-year] * [All Posts Grouped by Collection -- List View][posts-collection] * [Portfolio Collection -- Grid View][portfolio-collection] [posts-categories]: https://github.com/{{ site.repository }}/blob/master/docs/_pages/category-archive.html [posts-tags]: https://github.com/{{ site.repository }}/blob/master/docs/_pages/tag-archive.html [posts-year]: https://github.com/{{ site.repository }}/blob/master/docs/_pages/year-archive.html [posts-collection]: https://github.com/{{ site.repository }}/blob/master/docs/_pages/collection-archive.html [portfolio-collection]: https://github.com/{{ site.repository }}/blob/master/docs/_pages/portfolio-archive.html Post and page excerpts are auto-generated by Jekyll which grabs the first paragraph of text. To override this text with something more specific use the following YAML Front Matter: ```yaml excerpt: "A unique line of text to describe this post that will display in an archive listing and meta description with SEO benefits." ``` ### Grid View Adding `type=grid` to the `archive-single` helper will display archive posts in a 4 column grid. For example to create an archive displaying all documents in the portfolio collection: **Step 1:** Create a portfolio archive page (eg. `_pages/portfolio-archive.html`) with the following YAML Front Matter: ```yaml --- layout: archive title: "Portfolio" permalink: /portfolio/ author_profile: false --- ``` **Step 2:** Loop over all documents in the portfolio collection and output in a grid: ```html {% raw %}
{% for post in site.portfolio %} {% include archive-single.html type="grid" %} {% endfor %}{% endraw %}
``` To produce something like this:
archive grid view example
Grid view example.
**Note:** More information on using this `_include` can be found under [**Helpers**]({{ "/docs/helpers/" | absolute_url }}). {: .notice--info} ### Taxonomy Archive If you have the luxury of using Jekyll plugins the creation of category and tag archives is greatly simplified. Enable support for the [`jekyll-archives`](https://github.com/jekyll/jekyll-archives) plugin with a few `_config.yml` settings as noted in the [**Configuration**]({{ "/docs/configuration/#archive-settings" | absolute_url }}) section. ![archive taxonomy layout example]({{ "/assets/images/mm-layout-archive-taxonomy.png" | absolute_url }}) ### Home Page A derivative archive page layout to be used as a simple home page. It is built to show a paginated list of recent posts based off of the [pagination settings]({{ "/docs/configuration/#paginate" | absolute_url }}) in `_config.yml`.
paginated home page example
Example of a paginated home page showing 5 recent posts.
To use create `index.html` at the root of your project and add the following YAML Front Matter: ```yaml --- layout: home --- ``` Then configure pagination in `_config.yml`. ```yaml paginate: 5 # amount of posts to show paginate_path: /page:num/ ``` **Note:** Jekyll can only paginate a single `index.html` file. If you'd like to paginate more pages (e.g. category indexes) you'll need the help of a custom plugin. For more pagination related settings check the [**Configuration**]({{ "/docs/configuration/#paginate" | absolute_url }}) section. {: .notice--info} ## Splash Page Layout For full-width landing pages that need a little something extra add `layout: splash` to the YAML Front Matter. **Includes:** * Optional header image with caption * Optional header overlay (solid color/image) + text and optional "call to action" button * Feature blocks (`left`, `center`, and `right` alignment options) ![splash page layout example]({{ "/assets/images/mm-layout-splash.png" | absolute_url }}) Feature blocks can be assigned and aligned to the `left`, `right`, or `center` with a sprinkling of YAML. For full details on how to use the `feature_row` helper check the [**Content**]({{ "/docs/helpers/" | absolute_url }}) section or review a [sample splash page](https://github.com/{{ site.repository }}/blob/master/docs/_pages/splash-page.md). --- ## Headers To add some visual punch to a post or page, a large full-width header image can be included. Be sure to resize your header images. `~1280px` is a good width if you aren't [responsively serving up images](http://alistapart.com/article/responsive-images-in-practice). Through the magic of CSS they will scale up or down to fill the container. If you go with something too small it will look like garbage when upscaled, and something too large will hurt performance. **Please Note:** Paths for image headers, overlays, teasers, [galleries]({{ "/docs/helpers/#gallery" | absolute_url }}), and [feature rows]({{ "/docs/helpers/#feature-row" | absolute_url }}) have changed and require a full path. Instead of just `image: filename.jpg` you'll need to use the full path eg: `image: /assets/images/filename.jpg`. The preferred location is now `/assets/images/`, but can be placed elsewhere or external hosted. This all applies for image references in `_config.yml` and `author.yml` as well. {: .notice--danger} ![single layout header image example]({{ "/assets/images/mm-single-header-example.jpg" | absolute_url }}) Place your images in the `/assets/images/` folder and add the following YAML Front Matter: ```yaml header: image: /assets/images/image-filename.jpg ``` For externally hosted images include the full image path instead of just the filename: ```yaml header: image: http://some-site.com/assets/images/image.jpg ``` To include a caption or attribution for the image: ```yaml header: image: /assets/images/unsplash-image-1.jpg caption: "Photo credit: [**Unsplash**](https://unsplash.com)" ``` **ProTip:** Captions written in Markdown are supported, so feel free to add links, or style text. Just be sure to wrap it in quotes. {: .notice--info} ### Header Overlay To overlay text on top of a header image you have a few more options: | Name | Description | Default | | ---- | ----------- | ------- | | **overlay_image** | Header image you'd like to overlay. Same rules as `header.image` from above. | | | **overlay_filter** | Color/opacity to overlay on top of the header image eg: `0.5` or `rgba(255, 0, 0, 0.5)`. | | **excerpt** | Auto-generated page excerpt is added to the overlay text or can be overridden. | | | **cta_label** | Call to action button text label. | `more_label` in UI Text data file | | **cta_url** | Call to action button URL. | | With this YAML Front Matter: ```yaml excerpt: "This post should display a **header with an overlay image**, if the theme supports it." header: overlay_image: /assets/images/unsplash-image-1.jpg caption: "Photo credit: [**Unsplash**](https://unsplash.com)" cta_label: "More Info" cta_url: "https://unsplash.com" ``` You'd get a header image overlaid with text and a call to action button like this: ![single layout header overlay example]({{ "/assets/images/mm-single-header-overlay-example.jpg" | absolute_url }}) You also have the option of specifying a solid background-color to use instead of an image. ![single layout header overlay with background fill]({{ "/assets/images/mm-single-header-overlay-fill-example.jpg" | absolute_url }}) ```yaml excerpt: "This post should display a **header with a solid background color**, if the theme supports it." header: overlay_color: "#333" ``` You can also specifying the opacity (between `0` and `1`) of a black overlay like so: ![transparent black overlay]({{ "/assets/images/mm-header-overlay-black-filter.jpg" | absolute_url }}) ```yaml excerpt: "This post should [...]" header: overlay_image: /assets/images/unsplash-image-1.jpg overlay_filter: 0.5 # same as adding an opacity of 0.5 to a black background caption: "Photo credit: [**Unsplash**](https://unsplash.com)" cta_label: "More Info" cta_url: "https://unsplash.com" ``` Or if you want to do more fancy things, go full rgba: ![transparent red overlay]({{ "/assets/images/mm-header-overlay-red-filter.jpg" | absolute_url }}) ```yaml excerpt: "This post should [...]" header: overlay_image: /assets/images/unsplash-image-1.jpg overlay_filter: rgba(255, 0, 0, 0.5) caption: "Photo credit: [**Unsplash**](https://unsplash.com)" cta_label: "More Info" cta_url: "https://unsplash.com" ``` --- ## Sidebars The space to the left of a page's main content is blank by default, but has the ability to show an author profile (name, short biography, social media links), custom content, or both. ### Author Profile Add `author_profile: true` to a post or page's YAML Front Matter. ![single layout example]({{ "/assets/images/mm-layout-single.png" | absolute_url }}) Better yet, enable it with Front Matter Defaults set in `_config.yml`. ```yaml defaults: # _posts - scope: path: "" type: posts values: author_profile: true ``` **Note:** To disable the author sidebar profile for a specific post or page, add `author_profile: false` to the YAML Front Matter instead. {: .notice--warning} The theme comes pre-built with a selection of links for the most common social media networks. These are all optional and can be [assigned in `_config.yml`]({{ "/docs/configuration/" | absolute_url }}). To add more links you'll need to crack open [`_includes/author-profile.html`](https://github.com/mmistakes/minimal-mistakes/blob/master/_includes/author-profile.html) and make some edits. Inside of `