<p><ahref="#page_Layouts-Using-a-Keymap-with-Multiple-Keyboards">Layouts: Using a Keymap with Multiple Keyboards</a></p>
<ulclass="TableOfContents">
<li>
<p><ahref="#page_Supporting-a-Layout">Supporting a Layout</a></p>
</li>
<li>
<p><ahref="#page_Tips-for-Making-Layouts-Keyboard-Agnostic">Tips for Making Layouts Keyboard-Agnostic</a></p>
</li>
</ul>
</li>
</ul>
<h1id="page_Layouts-Using-a-Keymap-with-Multiple-Keyboards">Layouts: Using a Keymap with Multiple Keyboards</h1>
<p>The <code>layouts/</code> folder contains different physical key layouts that can apply to different keyboards.</p>
<pre><code>layouts/
+ default/
| + 60_ansi/
| | + readme.md
| | + layout.json
| | + a_good_keymap/
| | | + keymap.c
| | | + readme.md
| | | + config.h
| | | + rules.mk
| | + <keymap folder>/
| | + ...
| + <layout folder>/
+ community/
| + <layout folder>/
| + ...
</code></pre>
<p>The <code>layouts/default/</code> and <code>layouts/community/</code> are two examples of layout "repositories" - currently <code>default</code> will contain all of the information concerning the layout, and one default keymap named <code>default_<layout></code>, for users to use as a reference. <code>community</code> contains all of the community keymaps, with the eventual goal of being split-off into a separate repo for users to clone into <code>layouts/</code>. QMK searches through all folders in <code>layouts/</code>, so it's possible to have multiple repositories here.</p>
<p>Each layout folder is named (<code>[a-z0-9_]</code>) after the physical aspects of the layout, in the most generic way possible, and contains a <code>readme.md</code> with the layout to be defined by the keyboard:</p>
<pre><codeclass="language-md"># 60_ansi
LAYOUT_60_ansi
</code></pre>
<p>New names should try to stick to the standards set by existing layouts, and can be discussed in the PR/Issue.</p>
<h2id="page_Supporting-a-Layout">Supporting a Layout</h2>
<p>For a keyboard to support a layout, the variable must be defined in it's <code><keyboard>.h</code>, and match the number of arguments/keys (and preferably the physical layout):</p>
<pre><code>#define LAYOUT_60_ansi KEYMAP_ANSI
</code></pre>
<p>The name of the layout must match this regex: <code>[a-z0-9_]+</code></p>
<p>The folder name must be added to the keyboard's <code>rules.mk</code>:</p>
<pre><code>LAYOUTS = 60_ansi
</code></pre>
<p><code>LAYOUTS</code> can be set in any keyboard folder level's <code>rules.mk</code>:</p>
<pre><code>LAYOUTS = 60_iso
</code></pre>
<p>but the <code>LAYOUT_<layout></code> variable must be defined in <code><folder>.h</code> as well.</p>
<h2id="page_Tips-for-Making-Layouts-Keyboard-Agnostic">Tips for Making Layouts Keyboard-Agnostic</h2>
<p>Instead of using <code>#include "planck.h"</code>, you can use this line to include whatever <code><keyboard>.h</code> (<code><folder>.h</code> should not be included here) file that is being compiled:</p>
<pre><code>#include QMK_KEYBOARD_H
</code></pre>
<p>If you want to keep some keyboard-specific code, you can use these variables to escape it with an <code>#ifdef</code> statement:</p>