One of the features we wanted to add to the docs site when we moved it away from the home page was search, which you could do from any page of the site.
Since Jekyll is static, and Github Pages limits the number of plugins you can install, we decided to build our own solution.
First, we created a page called
This will generate a list of published posts and pages that have either not been ignored or have a layout of
Now, open your default layout page
_layouts/default.html, and add the following block of code to the bottom of the page:
And add this block where ever you want your search form to display:
<div class="container"> <div class="well" id="searchbox"> <input id="search-field" placeholder="Search the Site"/> <ul id="results"></ul> </div> </div>
This will search your
search.xml file and return results, I have it set to search as you type, but if you set the
false, then that will wait until you type enter.
You can change the
rss file to which ever url you want to use, and it will perform searches based on that.
This can be handy on blogs using Jekyll, not just on our docs site, hence why I wanted to share how it works. Actually, this is handy for any static blog, you just need a rss feed that you can search results on.
One other thing, any page that is set to
sitemap: false will get ignored from the
search.xml file and so won't show up in searches, like wise any page that has a