Issue in staging pages - URL Slug

Naresh Ede asked on July 2, 2024 16:40

Hello,

I am working on kentico 13.0.64.

I have content is different across environments. So I deleted all pages in the environment where I have outdated content, and setup the staging server from updated content environment.

When I synchronize pages, it is not properly synchronizing (all content sync correctly except URLs. Please see below screenshots

Source Server:

Image Text

Target Server:

Image Text

Is there any additional steps that we need to do to sync URLs properly?

Thanks, Naresh Ede

Correct Answer

Brenden Kehren answered on July 2, 2024 17:17

In the documentation, it states the following for syncing URLs of pages:

  • Change page URL path slug - the URL slug of the page (and path of its child pages) was changed.
  • Generate page URL paths - URL paths of pages were generated, as a result of, e.g. changed routing mode.
  • Update page URL paths - URL paths of pages were updated, as a result of, e.g. changed URL format.
  • Delete page URL paths- URL paths of pages were deleted, as a result of, e.g. changed routing mode.

Since none of those actions were actually performed during the "full sync", those paths are not updated/synced to the other environment. You'd have to manually trigger those by saving the page URL or creating some code to go through and create the tasks by doing "save action" in code.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on July 3, 2024 09:17

Just to explain bit more - the URL Slug is not part of the page object type (tree node) so it is not synchronized when you do a full sync. There must be an action made as explained by Brended, so appropriate staging task is created.

0 votesVote for this answer Mark as a Correct answer

Joel Dahlin answered on December 20, 2024 22:59

I've ran into this issue as well. Does anyone know how to create the Staging Task for the update in code? I have code to actually update the url slug, but no Staging task is created.

    private int CreateStagingTasks(string nodeAliasPath)
    {
        int count = 0;

        var pages = DocumentHelper.GetDocuments()
                                        .TopN(1)
                                        .Culture("en-us")
                                        .Path(nodeAliasPath, PathTypeEnum.Children)
                                        .OrderBy("NodeLevel, NodeOrder");

        if (!DataHelper.DataSourceIsEmpty(pages))
        {
            foreach (var page in pages)
            {
                var pageUrlPath = page.GetPageUrlPath("en-us");
                string currentSlug = pageUrlPath.Slug.ToLower();
                string tempSlug = $"{currentSlug}-temp";
                PageUrlPathSlugUpdater pageUrlPathSlugUpdater = new PageUrlPathSlugUpdater(page, page.DocumentCulture);

                IEnumerable<CollisionData> collidingPaths;

                pageUrlPathSlugUpdater.TryUpdate(tempSlug, out collidingPaths);

                if (collidingPaths.Count() == 0)
                {
                    pageUrlPathSlugUpdater.TryUpdate(currentSlug, out collidingPaths);
                    if (collidingPaths.Count() == 0)
                    {
                        count++;
                    }
                    else
                    {
                        // Slug wasn't updated
                    }
                }                    
            }
        }

        return count;
    }
0 votesVote for this answer Mark as a Correct answer

Joel Dahlin answered on December 21, 2024 01:13

In working with Support here is what I came up with:

        private int CreateStagingTasks(string nodeAliasPath)
    {
        int count = 0;

        var pages = DocumentHelper.GetDocuments()
                                        //.TopN(1)
                                        .Culture("en-us")
                                        .Path(nodeAliasPath, PathTypeEnum.Children)
                                        .OrderBy("NodeLevel, NodeOrder");

        if (!DataHelper.DataSourceIsEmpty(pages))
        {
            foreach (var page in pages)
            {
                if (!page.IsLink && page.HasUrl())
                {
                    try
                    {
                        var pageUrlPath = page.GetPageUrlPath("en-us");
                        if (pageUrlPath != null)
                        {
                            string currentSlug = pageUrlPath.Slug.ToLower();
                            LogChangeSlugTask(page, currentSlug, page.DocumentCulture);
                            count++;
                        }
                    }
                    catch { }
                }                    
            }
        }

        return count;
    }

    private void LogChangeSlugTask(TreeNode page, string newSlug, string cultureCode)
    {
        var parameters = new TaskParameters();
        parameters.SetParameter(SLUG_PARAM_NAME, newSlug);
        parameters.SetParameter(CULTURE_PARAM_NAME, cultureCode);

        DocumentSynchronizationHelper.LogDocumentChange(page, TaskTypeEnum.ChangePageUrlPathSlug, page.TreeProvider, SynchronizationInfoProvider.ENABLED_SERVERS, parameters, page.TreeProvider.AllowAsyncActions);
    }
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.