Configuring default metadata on document libraries helps ensure content is tagged with minimal user action required. There are many use cases, such as tagging project codes, departments, locations and document types. Default metadata can be configured on both metadata columns and folders within a library, allowing you to mix defaults that apply to all documents in a document library and specific values if a document is added to a folder within the library.
To configure default metadata, go to the Library, choose Library Settings and then click Column Default Values. Select the folder and configure the default value.
I had a scenario where we wanted to apply default metadata to folders within a document library and then repeat the same configuration across a series of project sites. Using ShareGate I copied my template site to create a new site, but the default folder metadata didn’t copy. I tried creating a document library using the “from existing library” option and it created the library with metadata but no folders or default metadata. Is there another way? Yes!
SharePoint stores the configuration file for default metadata in a file hidden in the “Forms” folder, hidden in the document library called client_locationbaseddefaults.html. In the old days, we could navigate to the file using SharePoint Designer, but in the modern era, we need a different approach.
The configuration looks like this. Each line contains the path to the file, field name and default value. Note the file does not exist if there is no default metadata configured.
- Download the Defaults file from the template library
- https://tenantURL/site/library/forms/client_locationbaseddefaults.html
- copy the file from downloads to the folder you are in for PowerShell
- Edit the html file to replace the path for library (only if you are changing the name of the library)
- Upload to the new site:
- Connect-PnPOnline -url <siteURL> -userweblogin
- add-pnpfile -Path “client_LocationBasedDefaults.html” -folder “shared documents\forms”
Go back to your library and check the default metadata settings!
In the commands above I use Add-PnPFile documentation to upload the file back to the hidden Forms folder in the document library.
Note that you can also use PnP PowerShell to add column defaults via a PowerShell script with the Set-PnPDefaultColumnValues commandlet.
It is also possible to configure defaults using API calls from Power Automate or a development tool of your choice.