Skip to content

Instantly share code, notes, and snippets.

@jonathanmooredigital
Created April 21, 2023 08:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanmooredigital/8e3423b680751ecde7425cd2e7c4d671 to your computer and use it in GitHub Desktop.
Save jonathanmooredigital/8e3423b680751ecde7425cd2e7c4d671 to your computer and use it in GitHub Desktop.
April 2023 Brighton SEO Xpath Examples
/*
========================================================================
Brighton SEO April 2023 - The XPath to Discovery
https://www.linkedin.com/in/moorejonathan/
https://twitter.com/nathanless
========================================================================
*/
Decendants
//footer//a
Exact match
//meta[@name="description"]
Contains
//meta[contains(@property,"og:")]
And
//script[@src and @defer]
Or
//link[contains(@rel, "next") or contains(@rel, "prev")]
Negation
//img[not(@alt]
Text
//a[contains(text(),"for sale in Mayfair")]
Href lang atributes
//link[@rel="alternate"]/@hreflang
Data attributes
//*/@*[starts-with(name(),"data-")]
Resource hints
//link[ contains(@rel, "dns-prefetch") or contains(@rel, "preconnect") or contains(@rel, "preload") or contains(@rel, "prefetch") or contains(@rel, "prerender")]
Header elements
//*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6]
Invalid <head> tags
//head/*[self::img or ::iframe or self::noscript]
Picture elements
//picture/img
Images not lazy loaded
//img[not(contains(@loading,"lazy" or contains(@class, "lazy") or contains(@class, "lazyloaded"))]
URLs with trailing slash
//a[substring(@href, string-length(@href) = '/')]
URLs without trailing slash
//a[not(substring(@href, string-length(@href)) = '/')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment