Thank you Brenden, but my issue was with retrieving Tags and Categories on pages not how to create Tags and Categories.
I managed to find a way to retrieve Tags on pages but I'm still struggle with Categories.
Here's how I retrieved page Tags:
Code
string pagePath = "/YourPagePath";
// Get the specific page by its path
TreeNode page = DocumentHelper.GetDocuments()
.Path(pagePath)
.OnCurrentSite()
.FirstOrDefault();
if (page != null)
{
// Get tags associated with the page
string[] pageTags = page.DocumentTags.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
if (pageTags.Any())
{
Console.WriteLine("Tags for the page:");
foreach (var tag in pageTags)
{
Console.WriteLine(tag);
}
}
else
{
Console.WriteLine("No tags found for the page.");
}
}
else
{
Console.WriteLine($"Page with path '{pagePath}' not found.");
}
Code