SEARCHABLE
Both keyup and url parameter search.
Search is performed on every field keyup
event, via ajax calling of search.json
file where target fields are collected for every post:
{
"title" : "{{ post.title }}",
"url" : "{{ post.url }}",
"date" : "{{ post.date | date: "%e %B %Y" }}",
"tags" : "{% for tags in post.tags %}{{ tags }}{% if forloop.last %}{% else %}, {% endif %}{% endfor %}",
"excerpt" : "{{ post.excerpt | strip_html }}",
"category" : "{{ post.category }}"
}
Search results div is populated by template
setting variabile in assets/js/simpleJekyllSearch.js
which is now set like _includes/archive-item.html
.
You can pass query string to search page as url parameter so you can careate filter links like /search/?string=specific-tag
or /search/?string=genuary 2014
.
Customize search
- If you need to restrict search on custom post fields just add them in post front-matter:
---
layout: post
title: my title
customkey: yellow
---
-
Add in
pages/search.json
a call"customkey" : "{{ post.customkey }}"
-
You can show custom keys on search results tweaking
template
var inassets/js/simpleJekyllSearch.js
using{customkey}
.