APIsChangelog
Log In

Page information

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)

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)

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)

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)

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)

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)

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)


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)

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}

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}