0
0
SEO Fundamentalsknowledge~30 mins

URL structure and slug optimization in SEO Fundamentals - Mini Project: Build & Apply

Choose your learning style9 modes available
URL Structure and Slug Optimization
📖 Scenario: You are managing a website that sells different types of fruits. You want to create clear and SEO-friendly URLs for each fruit page so visitors and search engines can easily understand what the page is about.
🎯 Goal: Build a simple URL structure with optimized slugs for fruit pages that are easy to read, consistent, and good for search engines.
📋 What You'll Learn
Create a dictionary with fruit names and their original URLs
Add a configuration variable for the base URL of the website
Generate optimized slugs by converting fruit names to lowercase and replacing spaces with hyphens
Combine the base URL and slugs to form full SEO-friendly URLs
💡 Why This Matters
🌍 Real World
Clear and optimized URLs help users understand page content and improve search engine rankings.
💼 Career
SEO specialists and web developers use URL structure and slug optimization to enhance website visibility and user experience.
Progress0 / 4 steps
1
Create the initial fruit URLs dictionary
Create a dictionary called fruit_urls with these exact entries: 'Apple': '/Fruits/Apple', 'Banana': '/Fruits/Banana', 'Dragon Fruit': '/Fruits/Dragon Fruit', 'Elderberry': '/Fruits/Elderberry'
SEO Fundamentals
Need a hint?

Use curly braces to create a dictionary with the exact fruit names as keys and their URLs as values.

2
Add the base URL configuration
Create a variable called base_url and set it to the string 'https://www.fruitstore.com'
SEO Fundamentals
Need a hint?

Assign the website's main address to the variable base_url.

3
Generate optimized slugs for each fruit
Create a new dictionary called optimized_slugs that maps each fruit name to a slug. The slug should be the fruit name in lowercase with spaces replaced by hyphens. Use a dictionary comprehension with for fruit in fruit_urls.keys().
SEO Fundamentals
Need a hint?

Use fruit.lower().replace(' ', '-') inside a dictionary comprehension to create slugs.

4
Combine base URL and slugs to form full URLs
Create a dictionary called full_urls that maps each fruit name to its full SEO-friendly URL. Combine base_url, the string '/fruits/', and the slug from optimized_slugs for each fruit using a dictionary comprehension with for fruit in optimized_slugs.
SEO Fundamentals
Need a hint?

Use an f-string inside a dictionary comprehension to combine the parts into full URLs.