Socket
Book a DemoInstallSign in
Socket

github.com/dnb-org/components/search-algolia

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/dnb-org/components/search-algolia

Source
Go
Version
v1.4.13
Version published
Created
Source

DNB Hugo Component / Search Algolia

This is a Hugo theme component with helpers to add an Algolia powered search to your website.

Installing

First enable modules in your own repository:

hugo mod init github.com/username/reponame

Then add this module to your required modules in config.toml.

[module]
[[module.imports]]
path = "github.com/dnb-org/components/search-algolia"

The next time you run hugo it will download the latest version of the module.

To make this component work you need to add Algolia to your home output formats:

[outputs]
home = [ ... others ... , "Algolia" ]

You already should have an [output] section, add "Algolia" to it. Do not add it anywhere other than in the home directive.

Adding the search to your content

content/search/index.md

---
title: Search
description: Search in all articles
url: /search
---

{{< search >}}

Add your items to the search index

Install atomic-algolia:

npm install -D atomic-algolia

Once you configured your search index at algolia you can add new items in your deploy script. Add the following lines to your package.json (the sections might exist, so don't re-create them).

Add a script to your package.json configuration

{
  "scripts": {
    "algolia": "hugo --quiet && atomic-algolia && rm -rf public"
  }
}

Add the index creation to your deployment process:

npm run algolia

Updating

hugo mod get -u github.com/dnb-org/components/robots
hugo mod get -u # update all modules

Other components in DNB Hugo components

Other elements in DNB Hugo

DNB Hugo are the elements that enhance and simplify your daily work with Hugo, the world's fastest framework for building websites. Included are:

ElementDescription
blocksBlocks are reusable page elements like headers, footers, content display etc.
componentsComponents are preconfigured features like automatic search index creation, sitemap and robots.txt creation, etc.
librariesLibraries are a collection of often used external packages, conveniently configured as modules for Hugo.
shortcodesShortcodes are content particles that helpfully solve repeated tasks, like presentation, galleries and so on.
testcontentTestcontent is a collection of testing content. Obviously.

FAQs

Package last updated on 09 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts