up.history up.history.config
Configuration object

Configures behavior when the user goes back or forward in browser history.


History

[config.restoreTargets=['body']]
optional

A list of possible CSS selectors to replace when the user goes back or forward in history.

If more than one target is configured, the first selector matching both the current page and server response will be updated.

If nothing is configured, the <body> element will be replaced.

Type: Array
[config.enabled=true]
optional

Configures which aspects of history fragment updates can update.

If set to true, Unpoly may change the browser URL, the window title, meta tags and the <html> element's [lang] attribute.

If set to false, Unpoly will never change any of these.

To only update some aspects, set an array of the aspects Unpoly may update:

Aspect Updates
'location' The browser URL and history entries.
'title' The window title.
'metaTags' Meta tags in the <head>.
'lang' The <html> element's [lang] attribute.

For example, this configuration never changes the browser URL, but still updates the [lang] attribute when the user switches to another language:

up.history.config.enabled = ['lang']

An empty array has the same effect as false.

Render options can only narrow this setting, never update an aspect that it excludes. An overlay without visible history never updates history, regardless of this setting.

See Turning off history aspects for the consequences of excluding an aspect.

Type: boolean | Array<string>

Meta tags

[config.updateMetaTags]
optional

Configures whether history changes update meta tags in addition to the document's title and URL.

Type: boolean
[config.metaTagSelectors]
optional

An array of CSS selectors matching default meta tags that are updated during history changes.

By default, the following elements are matched:

  • All meta elements
  • A link[rel="alternate"] element
  • A link[rel="canonical"] element
  • A link[rel="icon"] element
  • JSON-LD annotations

You can include additional elements by assigning an [up-meta] attribute or by pushing their selector into this configuration array.

Only elements in the <head> can be matched. Elements in the <body> are never considered, even if they match one of the configured selectors.

Type: Array<string>
[config.noMetaTagSelectors]
optional

Exceptions to up.history.config.metaTagSelectors.

Matching elements will not be considered meta tags even if they match up.history.config.metaTagSelectors.

Type: Array<string>