Skip to content

Add HTML lang attribute SEO check#124

Open
aouwalitshikkha wants to merge 1 commit into
sethblack:mainfrom
aouwalitshikkha:add-html-lang-check
Open

Add HTML lang attribute SEO check#124
aouwalitshikkha wants to merge 1 commit into
sethblack:mainfrom
aouwalitshikkha:add-html-lang-check

Conversation

@aouwalitshikkha

Copy link
Copy Markdown

Summary

Adds a new SEO check that warns when the <html> tag is missing a lang attribute or has an empty lang attribute. This is a basic accessibility and SEO best practice — the lang attribute helps search engines and assistive technologies determine the page's language.

Fixes #84

Changes

  • pyseoanalyzer/page.py: Added analyze_html_lang() method that checks for a lang attribute on the <html> element. Called from analyze() alongside the other basic checks (H1, images, OG tags).

  • tests/test_page.py: Added 3 tests:

    • test_analyze_html_lang_missing — warns when <html lang> is absent
    • test_analyze_html_lang_present — no warning when lang="en" is present
    • (coverage for empty lang="" is handled by the same logic — get("lang") returns "" which is falsy)

Pattern

Follows the exact same pattern as the existing analyze_h1_tags(), analyze_img_tags(), and analyze_og() methods — uses soup_lower (lowercased BeautifulSoup), calls self.warn(), no CLI flag needed since it's a core SEO check that always runs.

Detects missing or empty lang attribute on <html> tag and
reports it as a warning. Follows the same pattern as existing
checks (h1, img alt, og tags).

Closes sethblack#84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible error with sitemap crawling

1 participant