Pagefind CLI configuration options

The Pagefind CLI has the following options. These can be set via any configuration source.

These configuration options only apply when running the Pagefind indexing tool on your site. For configuring Pagefind search in the browser, see Pagefind Search Config. For configuring the Pagefind Component UI, see Pagefind Component UI.

Required arguments

Site

The location of your built static site.

CLI FlagENV VariableConfig Key
--site <PATH>PAGEFIND_SITEsite

Optional arguments

Serve

Serve the site directory after creating the search index. Useful for testing search on a local build of your site without having to serve the site directory manually.

CLI FlagENV VariableConfig Key
--servePAGEFIND_SERVEserve

Output subdirectory

The folder to output the search bundle into, relative to the processed site. Defaults to pagefind.

CLI FlagENV VariableConfig Key
--output-subdir <DIR>PAGEFIND_OUTPUT_SUBDIRoutput_subdir

Output path

The folder to output the search bundle into, relative to the working directory. Overrides output-subdir if supplied.

CLI FlagENV VariableConfig Key
--output-path <PATH>PAGEFIND_OUTPUT_PATHoutput_path

Root selector

The element that Pagefind should treat as the root of the document. Defaults to html.

Note that filters and metadata outside of this selector will not be detected, all Pagefind behaviour will be limited to this element and below. In most cases, you should use the data-pagefind-body attribute detailed in Customizing the index.

CLI FlagENV VariableConfig Key
--root-selector <S>PAGEFIND_ROOT_SELECTORroot_selector

Exclude selectors

Pass extra element selectors that Pagefind should ignore when indexing. For example, in pagefind.yml:

exclude_selectors:
  - "#my_navigation"
  - "blockquote > span"
  - "[id^='prefix-']"

All children will also be ignored, so using a #my_navigation * selector is not required — in other words, the semantics are the same as the data-pagefind-ignore attribute.

Note that currently Pagefind only supports lists of options via configuration files. If using the --exclude-selectors CLI flag or the PAGEFIND_EXCLUDE_SELECTORS environment variable, only one selector may be supplied. The selector may be a comma-separated CSS selector though, so the above example can be passed as --exclude-selectors "#my_navigation, blockquote > span, [id^='prefix-']".

CLI FlagENV VariableConfig Key
--exclude-selectors <S>PAGEFIND_EXCLUDE_SELECTORSexclude_selectors

Include characters

Prevents Pagefind from stripping the provided characters when indexing content. Allows users to search for words including these characters.

See Indexing special characters for more documentation.

Care is needed if setting this argument via the CLI, as special characters may be interpreted by your shell. Configure this via a configuration file if you encounter issues.

include_characters: "<>$"
CLI FlagENV VariableConfig Key
--include-characters <S>PAGEFIND_INCLUDE_CHARACTERSinclude_characters

Glob

Configures the glob used by Pagefind to discover HTML files. Defaults to **/*.{html}. See Wax patterns documentation for more details.

CLI FlagENV VariableConfig Key
--glob <GLOB>PAGEFIND_GLOBglob

Force language

Ignores any detected languages and creates a single index for the entire site as the provided language. Expects an ISO 639-1 code, such as en or pt.

See Multilingual search for more details.

CLI FlagENV VariableConfig Key
--force-language <LANG>PAGEFIND_FORCE_LANGUAGEforce_language

Keep index URL

Keeps index.html at the end of search result paths. By default, a file at animals/cat/index.html will be given the URL /animals/cat/. Setting this option to true will result in the URL /animals/cat/index.html.

CLI FlagENV VariableConfig Key
--keep-index-urlPAGEFIND_KEEP_INDEX_URLkeep_index_url

Write playground

Writes the Pagefind playground files to /playground within your bundle directory. For most sites, this will make the Pagefind playground available at /pagefind/playground/.

This defaults to false, so playground files are not written to your live site. Playground files are always available when running Pagefind with --serve.

CLI FlagENV VariableConfig Key
--write-playgroundPAGEFIND_WRITE_PLAYGROUNDwrite_playground

Verbose

Prints extra logging while indexing the site. Only affects the CLI, does not impact web-facing search.

CLI FlagENV VariableConfig Key
--verbosePAGEFIND_VERBOSEverbose

Quiet

Only logs errors and warnings while indexing the site. Only affects the CLI, does not impact web-facing search.

CLI FlagENV VariableConfig Key
--quietPAGEFIND_QUIETquiet

Silent

Only logs errors while indexing the site. Only affects the CLI, does not impact web-facing search.

CLI FlagENV VariableConfig Key
--silentPAGEFIND_SILENTsilent

Logfile

Writes logs to the given logfile, in addition to the console. Replaces the file on each run.

CLI FlagENV VariableConfig Key
--logfile <PATH>PAGEFIND_LOGFILElogfile
References