string siteUrl = "https://contoso.sharepoint.com/sites/mytestsite";
string targetSiteUrl = "https://contoso.sharepoint.com/sites/mytargetsite";
string userName = "[email protected]";
AuthenticationManager am = new AuthenticationManager();
using (var cc = am.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, GetSecureString("Password")))
{
using (var ccTarget = cc.Clone(targetSiteUrl))
{
var pageTransformator = new PageTransformator(cc, ccTarget);
var pages = cc.Web.GetPages();
foreach (var page in pages)
{
PageTransformationInformation pti = new PageTransformationInformation(page)
{
// If target page exists, then overwrite it
Overwrite = true,
};
try
{
Console.WriteLine($"Transforming page {page.FieldValues["FileLeafRef"]}");
pageTransformator.Transform(pti);
}
catch(ArgumentException ex)
{
Console.WriteLine($"Page {page.FieldValues["FileLeafRef"]} could not be transformed: {ex.Message}");
}
}
}
}
the above code is provided by microsoft to transform classic pages to modern UI but it is defaulted to allow only pages library.
Can anyone suggest if there are any other options to handle custom site pages or pages from other libraries.
reference to the microsoft documentation : Classic to modern UI transformation via .Net solution