{"id":15064508,"url":"https://github.com/slashdotdash/jekyll-lunr-js-search","last_synced_at":"2025-10-05T01:30:54.099Z","repository":{"id":7206611,"uuid":"8511996","full_name":"slashdotdash/jekyll-lunr-js-search","owner":"slashdotdash","description":"[UNSUPPORTED] Jekyll + lunr.js = static websites with powerful full-text search using JavaScript","archived":true,"fork":false,"pushed_at":"2018-02-05T22:11:57.000Z","size":520,"stargazers_count":546,"open_issues_count":39,"forks_count":109,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-09-29T00:55:04.697Z","etag":null,"topics":["jekyll","lunr","search","static-site-generator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slashdotdash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-01T22:56:01.000Z","updated_at":"2025-07-22T03:04:38.000Z","dependencies_parsed_at":"2022-08-24T20:10:32.660Z","dependency_job_id":null,"html_url":"https://github.com/slashdotdash/jekyll-lunr-js-search","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/slashdotdash/jekyll-lunr-js-search","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotdash%2Fjekyll-lunr-js-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotdash%2Fjekyll-lunr-js-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotdash%2Fjekyll-lunr-js-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotdash%2Fjekyll-lunr-js-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slashdotdash","download_url":"https://codeload.github.com/slashdotdash/jekyll-lunr-js-search/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotdash%2Fjekyll-lunr-js-search/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278399626,"owners_count":25980330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jekyll","lunr","search","static-site-generator"],"created_at":"2024-09-25T00:19:44.249Z","updated_at":"2025-10-05T01:30:53.707Z","avatar_url":"https://github.com/slashdotdash.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Jekyll](http://jekyllrb.com/) + [lunr.js](http://lunrjs.com/) = Static websites with powerful full-text search using JavaScript\n\nUse [lunr.js](http://lunrjs.com/) to provide simple full-text search, using JavaScript in your browser, for your Jekyll static website.\n\nInspired by Pascal Widdershoven's [Jekyll + indextank](https://github.com/PascalW/jekyll_indextank) and Michael Levin's [Sitemap.xml Generator](https://github.com/kinnetica/jekyll-plugins) plugins.\n\nThis Jekyll plugin handles the generation of a lunr.js compatible `.json` index file. Runtime search configuration is provided by a simple jQuery plugin.\n\nIt allows full-text search of all your Jekyll pages and posts. Executed by the client without any server-side processing (outside of serving static files).\n\n## How to use\n\n### 1. Install the plugin\n\nChoose to install as either a Ruby Gem, or by copying the pre-built plugin file to your Jekyll site.\n\n#### 1a. Install as a Ruby Gem\n\n1. Install the [jekyll-lunr-js-search](https://rubygems.org/gems/jekyll-lunr-js-search) Ruby Gem.\n\n        gem install jekyll-lunr-js-search\n\n2. Modify your Jekyll `_config.yml` file to include the Gem.\n\n        gems: ['jekyll-lunr-js-search']\n\n#### 1b. Install by copying the plugin to your Jekyll site.\n\n1. Place `build/jekyll_lunr_js_search.rb` inside the `_plugins` folder in the root of your Jekyll site.\n\nThe content from all Jekyll posts and pages will be indexed to a `js/index.json` file ready for lunr.js to consume. This happens each time the site is generated.\n\nA jQuery plugin is provided in `js/jquery.lunr.search.js` to handle the configuration of lunr.js with the search index JSON data generated by this plugin.\n\nDependencies for the jQuery plugin are as follows.\n\n* [jQuery](http://jquery.com)\n* [lunr.js](http://lunrjs.com)\n* [Mustache.js](https://github.com/janl/mustache.js)\n* [date.format.js](http://blog.stevenlevithan.com/archives/date-time-format)\n* [URI.js](http://medialize.github.com/URI.js/)\n\nA pre-built version of the jQuery plugin, along with all of the above dependencies, concatenated and minified is available from at [build/search.min.js](https://github.com/slashdotdash/jekyll-lunr-js-search/blob/master/build/search.min.js).\n\n### 2. Copy the jQuery plugin and add a script reference.\n\n#### 2a. Using the pre-built, minified plugin from the gem.\n\nThe plugin will automatically add the minified JavaScript file `js/search.min.js` to your `_site`.\n\nTo use it, you must add a script reference to the bottom of your nominated search page.\n\n        \u003cscript src=\"/js/search.min.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n\n#### 2b. Using the jQuery plugin and managing its dependencies yourself.\n\n1. Copy `js/jquery.lunr.search.js` to your Jekyll site's JavaScript directory.\n2. Add a script reference to the bottom of your nominated search page for `jquery.lunr.search.js` and each of the dependencies outlined above.\n\n        \u003cscript src=\"/js/jquery-1.9.1.min.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/js/lunr.min.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/js/mustache.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/js/date.format.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/js/URI.min.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/js/jquery.lunr.search.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n\nMake sure you use the same version of lunr.js as the gem. The Jekyll log output includes the version used.\n\nIdeally you would concatenate, minify and optimise these six `.js` files using uglify/Google closure/etc to produce a single `search.min.js` file to reference (or use the pre-built script as described in 2a above).\n\n    \u003cscript src=\"/js/search.min.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e\n\n### 4. Add a search form with a query input as shown.\n\n    \u003cform action=\"/search\" method=\"get\"\u003e\n      \u003cinput type=\"text\" id=\"search-query\" name=\"q\" placeholder=\"Search\" autocomplete=\"off\"\u003e\n    \u003c/form\u003e\n\nSearch happens as you type, once at least three characters have been entered.\n\nProviding the form action and specifying the get method allows the user to hit return/enter to also submit the search.\nAmend the form's action URL as necessary for the search page on your own site.\n\n### 5. Add an element to contain the list of search result entries.\n\n    \u003csection id=\"search-results\" style=\"display: none;\"\u003e \u003c/section\u003e\n\nThis may be initially hidden as the plugin will show the element when searching.\n\n### 6. Create a Mustache template to display the search results.\n\n    {% raw %}\n    \u003cscript id=\"search-results-template\" type=\"text/mustache\"\u003e\n      {{#entries}}\n        \u003carticle\u003e\n          \u003ch3\u003e\n            {{#date}}\u003csmall\u003e\u003ctime datetime=\"{{pubdate}}\" pubdate\u003e{{displaydate}}\u003c/time\u003e\u003c/small\u003e{{/date}}\n            \u003ca href=\"{{url}}\"\u003e{{title}}\u003c/a\u003e\n          \u003c/h3\u003e\n          {{#is_post}}\n          \u003cul\u003e\n            {{#tags}}\u003cli\u003e{{.}} \u003c/li\u003e{{/tags}}\n          \u003c/ul\u003e\n          {{/is_post}}\n        \u003c/article\u003e\n      {{/entries}}\n    \u003c/script\u003e\n    {% endraw %}\n\nNote the use of `{% raw %}` and `{% endraw %}` to ensure the Mustache tags are not stripped out by Jekyll.\n\nThe fields available to display are as follows.\n\n#### entries\nList of search result entries (mandatory).\n#### date\nRaw published date for posts, or null for pages. Can be used to toggle display of the following dates in the template `{{#date}}has a date{{/date}} {{#!date}}no date{{/date}}`.\n#### pubdate\nPost published date, formatted as 'yyyy-mm-dd', to be used in a html5 `\u003ctime datetime=\"{{pubdate}}\"\u003e` element (posts only).\n#### displaydate\nPost published date, formatted as 'mmm dd, yyyy', such as Oct 12, 2012 (posts only)\n#### title\nTitle of the Jekyll page or post.\n#### url\nURL of the Jekyll page or post that can be used to create a hyperlink `\u003ca href=\"{{url}}\"\u003e{{title}}\u003c/a\u003e`.\n#### categories\nCategories (array) of the Jekyll page or post, can be used in a loop `{{#categories}}{{.}} {{/categories}}` to list them.\n#### tags\nTags (array) of the Jekyll page or post, can be used in a loop `{{#tags}}{{.}} {{/tags}}` to list them.\n#### is_post\nBooelan value, true if current result element is a post. Can be used to toggle display of specific elements in the template `{{#is_post}}is a post{{/is_post}}`\n\n### 7. Configure the jQuery plugin for the search input field.\n\n    \u003cscript type=\"text/javascript\"\u003e\n      $(function() {\n        $('#search-query').lunrSearch({\n          indexUrl  : '/js/index.json',           // url for the .json file containing search index data\n          results   : '#search-results',          // selector for containing search results element\n          template  : '#search-results-template', // selector for Mustache.js template\n          titleMsg  : '\u003ch1\u003eSearch results\u003ch1\u003e',   // message attached in front of results (can be empty)\n          emptyMsg  : '\u003cp\u003eNothing found.\u003c/p\u003e'     // shown message if search returns no results\n        });\n      });\n    \u003c/script\u003e\n\n### 8. To exclude pages from the search index.\n\nAdd the following `exclude_from_search` setting to any page's YAML config.\n\n    exclude_from_search: true\n\nOr add an array of exclusions (as individual regular expressions) to the site's `_config.yml` file.\n\n    lunr_search:\n      excludes: [rss.xml, atom.xml]\n\n### 9. Stop Words\n\nYou can also configure a stopwords file, and a minimum length of word to be included in the index file. This can be done by adding a search block to `_config.yml`. The default values are:\n\n    lunr_search:\n      stopwords: \"stopwords.txt\"\n      min_length: 3\n\nThe stopwords file must consist of one word per line, in lowercase, without punctuation.\n\n### 10. Alternate data directory\n\nYou can choose to store `index.json`, `search.min.js` and `lunr.min.js` in a different directory like this:\n\n    lunr_search:\n      js_dir: \"javascript\"\n\n## Demo\n\nSearch plugin is deployed to [10consulting.com/search](http://10consulting.com/search/).\nSome example search queries are [/search/?q=git](http://10consulting.com/search/?q=git), [/search/?q=cqrs](http://10consulting.com/search/?q=cqrs).\n\nIt also features on-demand loading of the search plugin `.js` when focusing into the search field on the [homepage](http://10consulting.com/). Look at the browser network requests clicking into the search input.\n\n## Building\n\nTo build the single `jekyll_lunr_js_search.rb` plugin file.\n\n### Requirements\n\nInstall [Bundler](http://bundler.io/) and then run the following.\n\n\tbundle install\n\nInstall [Bower](http://bower.io).\n\nTo build the plugin.\n\n    rake build\n\nThen copy `build/jekyll_lunr_js_search.rb` to your Jekyll site's `_plugins` folder and the `build/*.min.js` files to your site's `js` folder.\n\nIf you include the `.js` and `.js.map` files your browser developer console will link to the unminified code.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashdotdash%2Fjekyll-lunr-js-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslashdotdash%2Fjekyll-lunr-js-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashdotdash%2Fjekyll-lunr-js-search/lists"}