How to Plan Stable URLs for a Programming Blog

Keep a tutorial’s category out of its URL unless the category is part of what makes it a distinct page. A tutorial at /tutorials/csharp-async-await/ can move from a beginner collection to a concurrency collection without breaking anyone’s bookmarks. Put it at /beginner/csharp/async-await/, though, and that same editorial change leaves you with a choice: keep a misleading address or move the page and redirect the old one.

1. Map your content before you name your routes

Write down the kinds of pages you’ll publish and pick two or three real examples of each. A programming blog might have standalone tutorials, courses with lessons in a set order, topic landing pages, and a portfolio of sample projects. Include something you expect to publish later, like a second edition of a course. A route that fits your first three posts might not make room for two editions of the same lesson.

  • Standalone tutorial: /tutorials/csharp-async-await/ gives the tutorial a home without tying it to a skill level.
  • Course lesson: /courses/csharp-basics/variables/ makes sense when the lesson belongs to that course. Put lesson numbers in the navigation so you can reorder lessons without renaming them.
  • Topic landing page: /topics/concurrency/ can bring together tutorials in several languages without changing their addresses.
  • Project page: /projects/xna-platformer/ gives the project its own space, separate from the tutorials that explain how you built it.

Pick the simplest route map that fits your examples. If your site is mostly articles, a root-level slug like /csharp-async-await/ may be enough. The trade-off is that article slugs share the same space as fixed pages such as /about/ and any application routes you add later. A prefix like /tutorials/ makes the address a little longer, but it’s easier to see which part of the site owns the route. Reserve fixed names like feed and search wherever they could clash with a generated slug.

Don’t add a directory level just to match the main menu. You might group tutorials, projects, and career advice under “Learn” this year and split them up next year. Use breadcrumbs and landing pages to show those relationships without putting each one in the URL. And don’t assume a nested URL gives you a landing page at its parent path. Decide what readers should find there, then build that page explicitly.

Website sections and page paths sketched on a whiteboard

2. Give slugs a rule editors can follow

A slug is the readable identifier for a page, usually the last part of its path. For English-language tutorials, lowercase words separated by hyphens are a good default. Include enough detail to tell the page apart from similar ones. csharp-async-await is easier to scan than the-complete-beginner-guide-to-using-async-and-await-in-csharp. If you later change the headline from “A Beginner’s Guide to Async/Await” to “How Async/Await Works in C#,” keep the published slug.

Write down how to handle names with punctuation: use csharp for C# and cpp for C++, for example. A literal # in a URL starts a fragment. The browser can use it to jump to a heading, but it isn’t part of the path sent to the server. The Wikipedia overview of URL syntax explains how paths, queries, and fragments differ. That distinction helps when you’re turning a title with punctuation into a slug or making a particular view shareable.

Decide what to do when two pages would otherwise get the same slug. A CMS might append -2, but a descriptive qualifier tells readers more. For example, if two articles cover related concepts in different languages, use names like javascript-promises and csharp-tasks. While you’re in the CMS settings, check that editing a published headline doesn’t regenerate its slug.

Use dates and version numbers only when they identify the page

A date can help identify an archived release note. It’s less useful in the URL of a Git tutorial you plan to update for years. Put the publication and update dates on the page instead. Apply the same test to software versions: if you’ll revise a single C# tutorial as the language changes, leave the version out of the path. If you need to document two supported versions side by side, a route like /docs/v2/configuration/ lets readers bookmark the instructions that match their installation.

3. Decide what belongs in the path, query, or fragment

Give a distinct resource its own path, such as /topics/concurrency/ for a topic page. Use a query string when readers need to share or return to a particular view: /tutorials/?language=csharp&sort=newest opens a filtered list with the newest tutorials first. Use a fragment like #cancellation to jump to a section within a tutorial. If readers are likely to link to a heading, keep its anchor ID stable even if you edit the heading text.

Judge query parameters by what they change. If a tracking parameter leaves the tutorial unchanged, the canonical tag can identify the clean tutorial URL as the preferred one. Pagination is different: if page two shows a different set of tutorials, don’t automatically declare page one its canonical URL. If a filtered list deserves a landing page of its own, give it a deliberate address rather than treating every filter combination as a separate public landing page.

Keep private information out of paths, queries, and fragments. People paste URLs into messages and capture them in screenshots, and paths and query values can appear in access logs. Check permissions where you serve a tutorial preview or course dashboard. An address that’s hard to guess isn’t an access check.

4. Pick one public form and make the stack agree

Choose your preferred hostname, require HTTPS, and decide whether page paths end in a slash. Either /tutorials/csharp-async-await/ or /tutorials/csharp-async-await can work. The important part is that your application, hosting layer, and CMS agree. If both forms serve the same page, use the preferred form in navigation, the sitemap, and canonical tags. For ordinary public pages, permanently redirect supported alternatives to the preferred address.

Use your framework’s conventions when they fit. If your static site generator produces paths with trailing slashes for directory indexes, forcing slashless paths may mean writing rules you don’t need. Use the same URL helper in menus and templates instead of assembling paths by hand. Then paste a generated address into a fresh tab and reload it. If the route only works when you click through the site, it isn’t ready to share.

Be careful about rewriting incoming paths. Generating lowercase slugs is sensible; forcing every request to lowercase can break filenames or identifiers that are case-sensitive. And if your fallback serves the home page for every unknown path, it hides typos. Return a real 404 for unrecognized public pages, with a helpful error page if you have one.

5. Rehearse the launch with a route checklist

Make a backup before you change permalink settings, route definitions, or redirect rules. For a CMS, back up the database and site files or take a snapshot you can restore. For an application, commit route and configuration changes to version control and separately back up any content or slug mappings stored outside the repository. Know how you’ll restore the backup before testing a change that could affect every page.

Make a short list of addresses to try and write down what each should do. Run the checks on staging first, then repeat the important ones in production. Hosting and proxy rules can differ even when the application build is identical.

Test Expected result
Open a published tutorial at its preferred path The correct page returns 200. If it includes a canonical tag, the tag names the preferred address.
Open a supported alternate host or slash form A permanent redirect takes you to the preferred address, ideally in one hop.
Open and reload a course lesson directly The lesson loads without a visit to the course landing page first.
Open a known old tutorial address, if one exists A permanent redirect takes you to the equivalent new page.
Open a path that has never existed The response is a real 404, not a success status with error text.
Share a filtered listing or section link The recipient sees the intended listing state or section.

Check status codes and redirect hops in the browser’s Network panel. The final page alone won’t tell you how the browser got there. Compare the sitemap with the live public routes: it should contain the preferred addresses of pages you want indexed, not redirects, preview routes, or staging URLs. Check that important pages are reachable through site navigation, too. If a tutorial works when you paste in its URL but nothing on the site links to it, here’s how to find and fix orphaned pages.

Preserve addresses that have already been shared

Even a site that hasn’t officially launched can have old URLs. You might have linked to a tutorial from a public project README, shared it in a newsletter, or published it on another domain. If you control the old address and there’s an equivalent new page, redirect readers straight to it. For a public content page, that usually means a 301. Don’t send unrelated addresses to the home page just to avoid a 404. If you merged several tutorials, redirect their old addresses to the combined page only if it still answers what readers came for.

Before importing the rest of your content, try one ordinary editorial change on staging. Create a draft with punctuation in the headline, set the slug to csharp-async-await, and publish it. Now edit the headline. The tutorial should still load at the same path, and the listing should still link to it. If either check fails, fix the CMS setting or URL helper before you import more pages.