Get collection name from a CMS page

page.getCollectionName()

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

Syntax

1page.getCollectionName(): Promise<string>

Returns

Promise<string>

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

Example

1try{
2 // Get Current Page
3 const currentPage = (await webflow.getCurrentPage()) as Page
4
5 // Get Collection ID if page belongs to a collection
6 const collectionName = await currentPage.getCollectionName()
7 console.log(collectionName)
8 }
9catch (error) {
10 console.error([error.message, error.cause.tag])
11 }

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
Built with