Add HTML lang attribute SEO check#124
Open
aouwalitshikkha wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new SEO check that warns when the
<html>tag is missing alangattribute or has an emptylangattribute. This is a basic accessibility and SEO best practice — thelangattribute helps search engines and assistive technologies determine the page's language.Fixes #84
Changes
pyseoanalyzer/page.py: Addedanalyze_html_lang()method that checks for alangattribute on the<html>element. Called fromanalyze()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 absenttest_analyze_html_lang_present— no warning whenlang="en"is presentlang=""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(), andanalyze_og()methods — usessoup_lower(lowercased BeautifulSoup), callsself.warn(), no CLI flag needed since it's a core SEO check that always runs.