Get collection name from a CMS page

page.getCollectionName()

Get the name of the collection that generated the collection-generated page.

Syntax

page.getCollectionName(): Promise<string>

Returns

Promise<string>

A promise that resolves to the name of the collection that generated the page.

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])
}

Error Handling

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

TagMessage
ResourceMissingMissing ${page.id}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canReadPageSettingsAnyAnyAnyAny