For pages, it’s only if they are on the same level. As the first URL that you gave is a sub-page, it will only do that if there’s another sub-page of that parent page with the same URL slug.
Hello Tim,
WordPress indeed has a feature to prevent duplicate slugs by appending a “-2” to the slug of a page or post with the same title as an existing one. It doesn’t include parent pages when generating slugs for hierarchical URLs (parent and child pages). When you create a child page, it automatically becomes a part of the URL structure of its parent page. However, WordPress does not factor in the parent page when generating the slug for the child page. It only checks for uniqueness among other sibling pages and top-level pages.
domain/parent-page/child-page: This is a child page under “parent-page.” The slug for this child page is generated based on its title and sibling pages at the same hierarchy level. Since there are no sibling pages with the same title in the “parent-page” hierarchy, no “-2” is appended to the slug.
domain/child-page: This is a top-level page, not a child of any other page. The slug for this page is generated based on its title and sibling pages at the top level. If there are no other top-level pages with the same title, no “-2” is appended to the slug.