<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="generator" content="Jekyll v3.8.3"> <link type="application/atom+xml" rel="alternate" href="https://jekyllrb.com/feed.xml" title="Jekyll • Simple, blog-aware, static sites" /> <link rel="alternate" type="application/atom+xml" title="Recent commits to Jekyll’s master branch" href="https://github.com/jekyll/jekyll/commits/master.atom"> <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic,900"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" /> <link rel="stylesheet" href="/css/screen.css"> <link rel="icon" type="image/x-icon" href="/favicon.ico"> <!-- Begin Jekyll SEO tag v2.4.0 --> <title>Creating pages | Jekyll • Simple, blog-aware, static sites</title> <meta name="generator" content="Jekyll v3.8.3" /> <meta property="og:title" content="Creating pages" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="In addition to writing posts, you might also want to add static pages (content that isn’t date-based) to your Jekyll site. By taking advantage of the way Jekyll copies files and directories, this is easy to do." /> <meta property="og:description" content="In addition to writing posts, you might also want to add static pages (content that isn’t date-based) to your Jekyll site. By taking advantage of the way Jekyll copies files and directories, this is easy to do." /> <link rel="canonical" href="https://jekyllrb.com/docs/pages/" /> <meta property="og:url" content="https://jekyllrb.com/docs/pages/" /> <meta property="og:site_name" content="Jekyll • Simple, blog-aware, static sites" /> <meta property="og:type" content="article" /> <meta property="article:published_time" content="2018-06-08T11:29:03-07:00" /> <meta name="twitter:card" content="summary" /> <meta name="twitter:site" content="@jekyllrb" /> <meta name="google-site-verification" content="onQcXpAvtHBrUI5LlroHNE_FP0b2qvFyPq7VZw36iEY" /> <script type="application/ld+json"> {"description":"In addition to writing posts, you might also want to add static pages (content that isn’t date-based) to your Jekyll site. By taking advantage of the way Jekyll copies files and directories, this is easy to do.","@type":"BlogPosting","url":"https://jekyllrb.com/docs/pages/","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://jekyllrb.com/img/logo-2x.png"}},"headline":"Creating pages","dateModified":"2018-06-08T11:29:03-07:00","datePublished":"2018-06-08T11:29:03-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://jekyllrb.com/docs/pages/"},"@context":"http://schema.org"}</script> <!-- End Jekyll SEO tag --> <!--[if lt IE 9]> <script src="/js/html5shiv.min.js"></script> <script src="/js/respond.min.js"></script> <![endif]--> </head> <body class="wrap"> <header> <div class="flexbox"> <div class="center-on-mobiles"> <h1> <a href="/" class="logo"> <span class="sr-only">Jekyll</span> <img src="/img/logo-2x.png" width="140" height="65" alt="Jekyll Logo"> </a> </h1> </div> <nav class="main-nav hide-on-mobiles"> <ul> <li class=""> <a href="/">Home</a> </li> <li class="current"> <a href="/docs/home/">Docs</a> </li> <li class=""> <a href="/news/">News</a> </li> <li class=""> <a href="/help/">Help</a> </li> </ul> </nav> <div class="search hide-on-mobiles"> <input type="text" id="docsearch-input" placeholder="Search the docs…"> </div> <div class="meta hide-on-mobiles"> <ul> <li> <a href="https://github.com/jekyll/jekyll/releases/tag/v3.8.3">v3.8.3</a> </li> <li> <a href="https://github.com/jekyll/jekyll">GitHub</a> </li> </ul> </div> </div> <nav class="mobile-nav show-on-mobiles"> <ul> <li class=""> <a href="/">Home</a> </li> <li class="current"> <a href="/docs/home/">Docs</a> </li> <li class=""> <a href="/news/">News</a> </li> <li class=""> <a href="/help/">Help</a> </li> <li> <a href="https://github.com/jekyll/jekyll">GitHub</a> </li> </ul> </nav> </header> <section class="docs"> <div class="grid"> <div class="docs-nav-mobile unit whole show-on-mobiles"> <select onchange="if (this.value) window.location.href=this.value"> <option value="">Navigate the docs…</option> <optgroup label="Getting Started"> <option value="/docs/home/">Welcome</option> <option value="/docs/quickstart/">Quick-start guide</option> <option value="/docs/installation/">Installation</option> <option value="/docs/windows/">Jekyll on Windows</option> <option value="/docs/usage/">Basic Usage</option> <option value="/docs/structure/">Directory structure</option> <option value="/docs/configuration/">Configuration</option> </optgroup> <optgroup label="Your Content"> <option value="/docs/frontmatter/">Front Matter</option> <option value="/docs/posts/">Writing posts</option> <option value="/docs/drafts/">Working with drafts</option> <option value="/docs/pages/">Creating pages</option> <option value="/docs/static-files/">Static Files</option> <option value="/docs/variables/">Variables</option> <option value="/docs/collections/">Collections</option> <option value="/docs/datafiles/">Data Files</option> <option value="/docs/assets/">Assets</option> <option value="/docs/migrations/">Blog migrations</option> </optgroup> <optgroup label="Customization"> <option value="/docs/templates/">Templates</option> <option value="/docs/includes/">Includes</option> <option value="/docs/permalinks/">Permalinks</option> <option value="/docs/pagination/">Pagination</option> <option value="/docs/plugins/">Plugins</option> <option value="/docs/themes/">Themes</option> <option value="/docs/extras/">Extras</option> </optgroup> <optgroup label="Deployment"> <option value="/docs/github-pages/">GitHub Pages</option> <option value="/docs/deployment-methods/">Deployment methods</option> <option value="/docs/continuous-integration/">Continuous Integration</option> </optgroup> <optgroup label="Miscellaneous"> <option value="/docs/troubleshooting/">Troubleshooting</option> <option value="/docs/sites/">Sites using Jekyll</option> <option value="/docs/resources/">Resources</option> <option value="/docs/upgrading/0-to-2/">Upgrading from 0.x to 2.x</option> <option value="/docs/upgrading/2-to-3/">Upgrading from 2.x to 3.x</option> </optgroup> <optgroup label="Meta"> <option value="/docs/contributing/">Contributing</option> <option value="/docs/maintaining/">Maintaining Jekyll</option> <option value="/docs/conduct/">Code of Conduct</option> <option value="/docs/history/">History</option> </optgroup> </select> </div> <div class="unit four-fifths"> <article> <div class="improve right hide-on-mobiles"> <a href="https://github.com/jekyll/jekyll/edit/master/docs/_docs/pages.md"><i class="fa fa-pencil"></i> Improve this page</a> </div> <h1>Creating pages</h1> <p>In addition to <a href="../posts/">writing posts</a>, you might also want to add static pages (content that isn’t date-based) to your Jekyll site. By taking advantage of the way Jekyll copies files and directories, this is easy to do.</p> <h2 id="homepage">Homepage</h2> <p>Just about every web server configuration you come across will look for an HTML file called <code class="highlighter-rouge">index.html</code> (by convention) in the site’s root folder and display that as the homepage. Unless the web server you’re using is configured to look for some different filename as the default, this file will turn into the homepage of your Jekyll-generated site.</p> <div class="note"> <h5>ProTip™: Use layouts on your homepage</h5> <p> Any HTML file on your site can use layouts and/or includes, even the homepage. Common content, like headers and footers, make excellent candidates for extraction into a layout. </p> </div> <h2 id="where-additional-pages-live">Where additional pages live</h2> <p>Where you put HTML or <a href="https://daringfireball.net/projects/markdown/">Markdown</a> files for pages depends on how you want the pages to work. There are two main ways of creating pages:</p> <ul> <li>Place named HTML or <a href="https://daringfireball.net/projects/markdown/">Markdown</a> files for each page in your site’s root folder.</li> <li>Place pages inside folders and subfolders named whatever you want.</li> </ul> <p>Both methods work fine (and can be used in conjunction with each other), with the only real difference being the resulting URLs. By default, pages retain the same folder structure in <code class="highlighter-rouge">_site</code> as they do in the source directory.</p> <h3 id="named-html-files">Named HTML files</h3> <p>The simplest way of adding a page is just to add an HTML file in the root directory with a suitable name for the page you want to create. For a site with a homepage, an about page, and a contact page, here’s what the root directory and associated URLs might look like:</p> <div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">.</span> |-- _config.yml |-- _includes/ |-- _layouts/ |-- _posts/ |-- _site/ |-- about.html <span class="c"># => http://example.com/about.html</span> |-- index.html <span class="c"># => http://example.com/</span> |-- other.md <span class="c"># => http://example.com/other.html</span> └── contact.html <span class="c"># => http://example.com/contact.html</span> </code></pre></div></div> <p>If you have a lot of pages, you can organize those pages into subfolders. The same subfolders that are used to group your pages in our project’s source will exist in the <code class="highlighter-rouge">_site</code> folder when your site builds.</p> <h2 id="flattening-pages-from-subfolders-into-the-root-directory">Flattening pages from subfolders into the root directory</h2> <p>If you have pages organized into subfolders in your source folder and want to flatten them in the root folder on build, you must add the <a href="/docs/permalinks/">permalink</a> property directly in your page’s front matter like this:</p> <div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nn">---</span> <span class="na">title</span><span class="pi">:</span> <span class="s">My page</span> <span class="na">permalink</span><span class="pi">:</span> <span class="s">mypageurl.html</span> <span class="nn">---</span> </code></pre></div></div> <h3 id="named-folders-containing-index-html-files">Named folders containing index HTML files</h3> <p>If you don’t want file extensions (<code class="highlighter-rouge">.html</code>) to appear in your page URLs (file extensions are the default), you can choose a <a href="../permalinks/#builtinpermalinkstyles">permalink style</a> that has a trailing slash instead of a file extension.</p> <p>Note if you want to view your site offline <em>without the Jekyll preview server</em>, your browser will need the file extension to display the page, and all assets will need to be relative links that function without the server baseurl.</p> <div class="section-nav"> <div class="left align-right"> <a href="/docs/drafts/" class="prev">Back</a> </div> <div class="right align-left"> <a href="/docs/static-files/" class="next">Next</a> </div> </div> <div class="clear"></div> </article> </div> <div class="unit one-fifth hide-on-mobiles"> <aside> <h4>Getting Started</h4> <ul> <li class=""><a href="/docs/home/">Welcome</a></li> <li class=""><a href="/docs/quickstart/">Quick-start guide</a></li> <li class=""><a href="/docs/installation/">Installation</a></li> <li class=""><a href="/docs/windows/">Jekyll on Windows</a></li> <li class=""><a href="/docs/usage/">Basic Usage</a></li> <li class=""><a href="/docs/structure/">Directory structure</a></li> <li class=""><a href="/docs/configuration/">Configuration</a></li> </ul> <h4>Your Content</h4> <ul> <li class=""><a href="/docs/frontmatter/">Front Matter</a></li> <li class=""><a href="/docs/posts/">Writing posts</a></li> <li class=""><a href="/docs/drafts/">Working with drafts</a></li> <li class="current"><a href="/docs/pages/">Creating pages</a></li> <li class=""><a href="/docs/static-files/">Static Files</a></li> <li class=""><a href="/docs/variables/">Variables</a></li> <li class=""><a href="/docs/collections/">Collections</a></li> <li class=""><a href="/docs/datafiles/">Data Files</a></li> <li class=""><a href="/docs/assets/">Assets</a></li> <li class=""><a href="/docs/migrations/">Blog migrations</a></li> </ul> <h4>Customization</h4> <ul> <li class=""><a href="/docs/templates/">Templates</a></li> <li class=""><a href="/docs/includes/">Includes</a></li> <li class=""><a href="/docs/permalinks/">Permalinks</a></li> <li class=""><a href="/docs/pagination/">Pagination</a></li> <li class=""><a href="/docs/plugins/">Plugins</a></li> <li class=""><a href="/docs/themes/">Themes</a></li> <li class=""><a href="/docs/extras/">Extras</a></li> </ul> <h4>Deployment</h4> <ul> <li class=""><a href="/docs/github-pages/">GitHub Pages</a></li> <li class=""><a href="/docs/deployment-methods/">Deployment methods</a></li> <li class=""><a href="/docs/continuous-integration/">Continuous Integration</a></li> </ul> <h4>Miscellaneous</h4> <ul> <li class=""><a href="/docs/troubleshooting/">Troubleshooting</a></li> <li class=""><a href="/docs/sites/">Sites using Jekyll</a></li> <li class=""><a href="/docs/resources/">Resources</a></li> <li class=""><a href="/docs/upgrading/0-to-2/">Upgrading from 0.x to 2.x</a></li> <li class=""><a href="/docs/upgrading/2-to-3/">Upgrading from 2.x to 3.x</a></li> </ul> <h4>Meta</h4> <ul> <li class=""><a href="/docs/contributing/">Contributing</a></li> <li class=""><a href="/docs/maintaining/">Maintaining Jekyll</a></li> <li class=""><a href="/docs/conduct/">Code of Conduct</a></li> <li class=""><a href="/docs/history/">History</a></li> </ul> </aside> </div> <div class="clear"></div> </div> </section> <footer> <div class="grid"> <div class="unit one-third center-on-mobiles"> <p>The contents of this website are <br />© 2018 under the terms of the <a href="https://github.com/jekyll/jekyll/blob/master/LICENSE">MIT License</a>.</p> </div> <div class="unit two-thirds align-right center-on-mobiles"> <p> Proudly hosted by <a href="https://github.com"> <img src="/img/footer-logo.png" width="100" height="30" alt="GitHub • Social coding"> </a> </p> </div> </div> </footer> <script> var anchorForId = function (id) { var anchor = document.createElement("a"); anchor.className = "header-link"; anchor.href = "#" + id; anchor.innerHTML = "<span class=\"sr-only\">Permalink</span><i class=\"fa fa-link\"></i>"; anchor.title = "Permalink"; return anchor; }; var linkifyAnchors = function (level, containingElement) { var headers = containingElement.getElementsByTagName("h" + level); for (var h = 0; h < headers.length; h++) { var header = headers[h]; if (typeof header.id !== "undefined" && header.id !== "") { header.appendChild(anchorForId(header.id)); } } }; document.onreadystatechange = function () { if (this.readyState === "complete") { var contentBlock = document.getElementsByClassName("docs")[0] || document.getElementsByClassName("news")[0]; if (!contentBlock) { return; } for (var level = 1; level <= 6; level++) { linkifyAnchors(level, contentBlock); } } }; </script> <!-- Google Analytics (https://www.google.com/analytics) --> <script> !function(j,e,k,y,l,L){j.GoogleAnalyticsObject=y,j[y]||(j[y]=function(){ (j[y].q=j[y].q||[]).push(arguments)}),j[y].l=+new Date,l=e.createElement(k), L=e.getElementsByTagName(k)[0],l.src='https://www.google-analytics.com/analytics.js', L.parentNode.insertBefore(l,L)}(window,document,'script','ga'); ga('create', 'UA-50755011-1', 'jekyllrb.com'); ga('send', 'pageview'); </script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script> <script type="text/javascript"> docsearch({ apiKey: '50fe39c839958dfad797000f33e2ec17', indexName: 'jekyllrb', inputSelector: '#docsearch-input', enhancedSearchInput: true, debug: false // Set debug to true if you want to inspect the dropdown }); </script> </body> </html>