APIsChangelog
Log In
APIs

Page information

page.setMetadata()

Update the metadata properties of the page. This method allows developers to set multiple metadata properties for a page at once, providing flexibility in managing page details like titles, descriptions, and search settings.

Syntax

page.setMetadata(metadata: PageMetadata): Promise<null>

 

Parameters

Metadata

An object containing the metadata properties to be updated. Each property is optional, allowing selective updates.

Property Type Description
name string The name of the page.
slug string The slug or URL path for the page.
title string The title displayed in the browser's title bar or tab.
description string A brief description of the page.
isDraft boolean Indicates if the page is a draft.
usesTitle AsOpenGraphTitle boolean Use the page title as the Open Graph title.
openGraphTitle string The Open Graph title for social sharing.
usesDescriptionAs OpenGraphDescription boolean Use the page description as the Open Graph description.
openGraphDescription string The Open Graph description for social sharing.
openGraphImage string The URL of the Open Graph image for social sharing.
isExcludedFromSearch boolean Exclude the page from search engine indexing.
usesTitleAsSearchTitle boolean Use the page title as the search title.
searchTitle string The search title used by search engines.
usesDescription AsSearchDescription boolean Use the page description as the search description.
searchDescription string The search description used by search engines.
usesOpenGraphImage AsSearchImage boolean Use the Open Graph image as the search image.
searchImage string The URL of the image used by search engines.

Returns

Promise<null>

A promise that resolves to null

Example

// Get the current page from the infinite improbability drive
const currentPage = (await webflow.getCurrentPage()) as Page

// Update the metadata of the current page (don't panic!)
await currentPage.setMetadata({
  title: "Don't Panic",
  description: "A page dedicated to the Guide's wisdom and towels.",
  isDraft: false,
  openGraphTitle: "The Ultimate Guide",
  openGraphDescription: "All you need to know about life, the universe, and everything.",
  openGraphImage: "https://example.com/towel.png",
  isExcludedFromSearch: false,
  searchTitle: "Hitchhiker's Guide",
  searchDescription: "The Hitchhiker's Guide to the Galaxy — your ultimate reference.",
})

// Confirm the new metadata (remember your towel!)
const newTitle = await currentPage.getTitle()
const newDescription = await currentPage.getDescription()
console.log(`Updated Guide Title: ${newTitle}`)
console.log(`Updated Guide Description: ${newDescription}`)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canManagePageSettingsAnyAnyAnyAny

page.getKind()

Retrieve the specific category of the page. This method determines the type of page from a set of predefined categories, providing more granular information about the page’s purpose and functionality.

Syntax

page.getKind(): Promise<string>

Returns

Promise<string>

A promise that resolves to a string indicating the kind of the current page. The possible values are:

  • static
  • ecommerce
  • cms
  • userSystems
  • utility
  • staticTemplate

Example

// Get Current Page
const currentPage = (await webflow.getCurrentPage()) as Page

// Get the page
const pageKind = await currentPage.getKind()
console.log(`Page Category: ${pageKind}`)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canManagePageSettingsAnyAnyAnyAny

page.getName()

Retrieves the name of the page.

Syntax

page.getName(): Promise<string>

Returns

Promise<string>

A Promise that resolves to a string with the page name.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Get page name
const pageName = await currentPage.getName()
console.log(pageName)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny

page.setName(name)

Sets the name of the page to the provided value.

Syntax

page.getName(name: string): Promise<null>

Parameters

  • name:string - The new name to set for the page.

Returns

Promise<null>

A Promise that resolves to null when the page name is set.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Set page name
await currentPage.setName("My New Page")
console.log(pageName)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canManagePageSettingsAnyAnyAnyAny

page.getSlug()

Retrieves the slug of the page.

Syntax

webflow.getSlug(): Promise<string>

Returns

Promise<string>

A Promise that resolves to a string with the page slug.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Get page slug
const pageSlug = await currentPage.getSlug()
console.log(pageSlug)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny

page.setSlug(slug)

Sets the slug of the page to the provided value.

Syntax

webflow.setSlug(slug: string): Promise<null>

Parameters

  • slug:string - The new name to set for the page.

Returns

Promise<null>

A Promise that resolves to null when the page slug is set.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Set page Description
await currentPage.setSlug(slug)
const newSlug = await currentPage.getSlug()
console.log("Slug",newSlug)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canManagePageSettingsAnyAnyAnyAny

page.getPublishPath()

Retrieves the path that will be used when the page is published.

Syntax

webflow.getPublishPath(): Promise<null | string>

Returns

Promise<string>

A Promise that resolves to a string with the value of the page path.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Get page path
const pagePath = await currentPage.getPublishPath()
console.log(pagePath)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny

page.getTitle()

Retrieves the title of the page.

Syntax

webflow.getTitle(): Promise<string>

Returns

Promise<string>

A Promise that resolves to a string with the value of the page title.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Get page title
const pageTitle = await currentPage.getTitle()
console.log(pageTitle)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny

page.setTitle(title)

Sets the title of the page to the provided value.

Syntax

webflow.setTitle(title: string): Promise<null>

Parameters

  • title: string - The new title to set for the page.

Returns

Promise<null>

A Promise that resolves to null when the page title has been set.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Set page Title
await currentPage.setTitle("My New Title")
console.log(pageTitle)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canManagePageSettingsAnyAnyAnyAny

page.getDescription()

Retrieves the current description of the page.

Syntax

webflow.getDescription(): Promise<string>

Returns

Promise<string>

A Promise that resolves to a string containing the page description.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Get page Description
const pageDescription = await currentPage.getDescription()
console.log(pageDescription)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny

page.setDescription(description)

Sets the description of the page to the provided value.

Syntax

webflow.setDescription(description: string): Promise<null>

Parameters

  • description: string - The new description to set for the page.

Returns

Promise<null>

A Promise that resolves to null when the page description has been set.

Example

// Get Current Page
const currentPage = await webflow.getCurrentPage() as Page

// Set page Description
await currentPage.setDescription("My New Description")
console.log(pageDescription)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canManagePageSettingsAnyAnyAnyAny

page.getCollectionId()

Get the collection ID from a page that is automatically generated from a collection.

Syntax

page.getCollectionId(): Promise<string>

Returns

Promise<string>

A Promise that resolves to the collection ID

Example

try {
  // Get Current Page
  const currentPage = (await webflow.getCurrentPage()) as Page

  // Get Collection ID if page belongs to a collection
  const collectionId = await currentPage.getCollectionId()
  console.log(collectionId)
} catch (error) {
  console.error([error.cause.tag, error.message])
}

Errors

If the method fails to find a collection, the method will return an error with the following cause and message.

TagMessage
ResourceMissingMissing ${Page.id}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny

page.getCollectionName()

Get the collection name from a page that is automatically generated from a collection.

Syntax

page.getCollectionName(): Promise<string>

Returns

Promise<string>

A Promise that resolves to the collection name.

Example

try{
    // Get Current Page
    const currentPage = (await webflow.getCurrentPage()) as Page

    // Get Collection ID if page belongs to a collection
    const collectionName = await currentPage.getCollectionName()
    console.log(collectionName)
    }
catch (error) {
      console.error([error.message, error.cause.tag])
    }

Errors

If the method fails to find a collection, the method will return an error with the following cause and message.

TagMessage
ResourceMissingMissing ${Page.id}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny