Changing Blog Post URLs Programmatically in Sitefinity

When migrating legacy Sitefinity sites, old .aspx URLs often stick around. Here’s how to regenerate all your blog post slugs programmatically using the Sitefinity API — fast, safe, and consistent.

Changing Blog Post URLs Programmatically in Sitefinity

When migrating older Sitefinity projects, it’s not uncommon to end up with legacy URL structures — especially when moving from Sitefinity 3.x to 4.x and beyond.

Back in the day, Sitefinity 3.x used .aspx extensions for content URLs, while later versions dropped that convention. If you’ve migrated content and noticed that your blog posts still hold onto the old URLs, you can regenerate them in bulk with a few lines of code.

The example below uses the BlogsManager API to loop through all blog posts, clear the existing URL mappings, and rebuild them based on the post title.

📄 Loading migrate-blogposts.cs

How It Works

  1. Get all master blog posts using BlogsManager.GetManager().
  2. Check out each post so it can be modified.
  3. Clear existing URLs and set a new UrlName based on the post title.
  4. Recompile and validate the URLs using RecompileAndValidateUrls().
  5. Publish and save each post to apply the changes.

The regex ensures that your new URLs are lowercase and stripped of special characters, replacing them with dashes for consistency.

After running the script, all blog post URLs are instantly refreshed — removing the old .aspx extensions and giving you clean, modern slugs.

Why This Still Matters

Even though this snippet dates back to the early Sitefinity 4.x days, the concept is still relevant for anyone dealing with bulk URL corrections after migrations.
If you’ve ever imported large content sets or upgraded from older CMS versions, regenerating slugs like this can save hours of manual work.