Sub topic 1
URL Slugs, Internal Links, and Anchor Text for SEO
Prerequisites
You should know basic HTML, including the a element and its href attribute. You should also understand that a browser requests a page over HTTP and that SEO helps search engines find and interpret pages.
How Search Engines Find Pages Through Links
Search engines discover pages by following links. They begin with known URLs, such as submitted sitemaps or popular pages, then request pages and inspect their links. An internal link points from one page on your site to another page on the same site.
Links help search engines:
- Discover pages that are not in a sitemap.
- Understand which pages are related.
- Estimate which pages are important based on the site's linking pattern.
A page with no internal links pointing to it is an orphan page. Search engines may still discover it through external links or a sitemap, but internal links provide a clearer path.
The Parts of a URL
A URL, or Uniform Resource Locator, identifies a web resource:
https://example.com/guides/url-slugs/?lang=en#examples
httpsis the scheme, which specifies the access protocol.example.comis the host, or domain./guides/url-slugs/is the path.?lang=enis a query string that sends parameters.#examplesis a fragment that points to a location within the page.
The final meaningful segment of the path is often called the slug.
What a Slug Is and Why It Matters
A slug is the readable part of a URL that identifies a page. In /guides/url-slugs/, the slug is url-slugs.
A useful slug gives readers and search engines a quick clue about the page topic. It also makes links easier to inspect, copy, and remember. Treat a slug as a stable identifier. Changing it can invalidate bookmarks and existing links.
Writing Good Slugs
Use lowercase words separated by hyphens. Keep the slug short and descriptive. Remove dates, filler words, and unnecessary tracking values unless they identify distinct content. Avoid changing a published slug without a redirect.
import re
import unicodedata
def slugify(title, max_length=60):
text = unicodedata.normalize("NFKD", title)
text = text.encode("ascii", "ignore").decode("ascii").lower()
text = re.sub(r"[^a-z0-9]+", "-", text).strip("-")
return text[:max_length].rstrip("-")
print(slugify("Crème Brûlée Recipe: Easy & Quick!"))
# creme-brulee-recipe-easy-quickExercise
Create a slug for the page title “Internal Linking: A Practical Guide for SEO”.
Show answer
internal-linking-practical-guide-seo