0
0
SEO Fundamentalsknowledge~10 mins

URL structure and slug optimization in SEO Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a URL slug by replacing spaces with {{BLANK_1}}.

SEO Fundamentals
slug = title.replace(' ', '[1]')
Drag options to blanks, or click blank then click option'
A_
B*
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using underscores (_) instead of hyphens (-)
Using plus signs (+) which can be confusing in URLs
2fill in blank
medium

Complete the code to convert the slug to lowercase for better URL consistency.

SEO Fundamentals
slug = slug.[1]()
Drag options to blanks, or click blank then click option'
Alower
Btitle
Ccapitalize
Dupper
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalize() which only changes the first letter
Using upper() which makes letters uppercase
3fill in blank
hard

Fix the error in the code to remove special characters from the slug using {{BLANK_1}}.

SEO Fundamentals
import re
slug = [1](r'[^a-z0-9-]', '', slug)
Drag options to blanks, or click blank then click option'
Are.sub
Bre.match
Cre.search
Dre.split
Attempts:
3 left
💡 Hint
Common Mistakes
Using re.match which only checks the start of the string
Using re.search which finds but does not replace
Using re.split which splits the string instead of replacing
4fill in blank
hard

Fill both blanks to create a slug dictionary with keys as original titles and values as optimized slugs.

SEO Fundamentals
slug_dict = {title: title[1]().replace(' ', '[2]') for title in titles}
Drag options to blanks, or click blank then click option'
A.lower
B.upper
C-
D_
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase method instead of lowercase
Replacing spaces with underscores instead of hyphens
5fill in blank
hard

Fill all three blanks to filter titles longer than 5 characters and create slugs with lowercase and hyphens.

SEO Fundamentals
filtered_slugs = {title[1]: title[2]().replace(' ', '[3]') for title in titles if len(title) > 5}
Drag options to blanks, or click blank then click option'
A.upper
B.lower
C-
D.strip
Attempts:
3 left
💡 Hint
Common Mistakes
Skipping the strip method leading to unwanted spaces
Using uppercase instead of lowercase
Replacing spaces with underscores instead of hyphens