Git Product home page Git Product logo

hugo-search-fuse-js's Introduction

Hugo live search using Fuse.js and Mark.js

This is not a standalone theme. This is a Hugo theme component.

To use this component,

  1. Add this to your site's TOML config file:

    [module]
      [[module.imports]]
        path = "github.com/kaushalmodi/hugo-search-fuse-js"
  2. Run hugo mod tidy in your main site directory. The main site repo needs to be a Hugo module as well (it needs to have its own go.mod). To make it one, run hugo mod init <your site url or any unique string> in your site repo before you do this step.

  3. Create content/search.md with layout parameter set to "search", and output parameter set to ["html", "json"]. The content or body of this search.md is not used by the search.html template which is part of this theme component.

    Here is an example search.md:

    +++
    title = "Search"
    layout = "search"
    outputs = ["html", "json"]
    [sitemap]
      priority = 0.1
    +++

Requirements

You need to install the latest version of Go from https://go.dev/doc/install because this theme component requires hugo mod .. commands to work.

This update on switch to using Hugo Modules was last tested with Hugo v0.92.0.

  1. Your main theme must be structured using base template and blocks, and
  2. The base template needs to define main and footer blocks (shown in that previous link).

If the main theme does not meet these requirements, you will need to edit the search.html partial to make search work. You can find it in layouts/_default/search.html in this component.

What if the main theme does not have baseof.html?

You have two options:

  1. Edit the search.html to make it fit your theme.
  2. Upgrade the theme to use the new "base template and blocks" approach.

What if the main theme has baseof.html, but doesn't have the main and/or footer blocks?

It's very easy to add those blocks without breaking your existing theme.

To add the main block, add this to your baseof.html at the appropriate place:

{{ block "main" . }}{{ end }}

And similarly add the below if the footer block is missing:

{{ block "footer" . }}{{ end }}

For an example, see the baseof.html snippet in Hugo docs.

Credits

hugo-search-fuse-js's People

Contributors

kaushalmodi avatar robin-wils avatar lpar avatar mcfatem avatar srinidhibhat45 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.