--- date: 2019-12-06T01:21:00+01:00 description: "Howto add an 'internal search engine' into the static website, made with Hugo, and JQueryUI" draft: false tags: ["Hugo","search","JQuery"] title: "Hugo Search: an internal search engine (JQueryUI autocomplete)" translationKey: "hugo-jqueryui-autocomplete" --- ## Description Adding a function `search` into static website made with Hugo can be done in differents ways. We will code this simply with JQuery+UI, in few minutes. We will use the Hugo `site.Pages` variable, and the JQueryUI `autocomplete()` method. I assume you known how to add correctly the both JQuery and JQueryUI librairies on your site. ## Codes ### JQueryUI As explain into the description section, we use the events of the method `autocomplete()`. We build the `$projects` variable to iterate over the Hugo `$pages` variable with the Hugo `range` function. The JQuery code: ```js ``` ### HTML And for the simplest code HTML, we use two elements `input` as: ```html ``` * the first catch the searched text * the second return all found titles, and in the background the equivalent URL. * the syntax `{{ i18n "searchHolderTitle" }}` exists for the multilanguage context on this website; You can replace with your personal text. ### TL;DR The fully code: ```html