Canonical Link Extractor

Extract canonical-link href values from HTML source, preserving source order and resolving no URLs implicitly.

Description

A canonical link declares a preferred resource identity for indexing.

A canonical link declares a preferred resource identity for indexing. Multiple declarations in source can conflict, so the tool preserves them for inspection.1

Extract canonical-link href values from HTML source, preserving source order and resolving no URLs implicitly.

When to use Canonical Link Extractor

Use this tool to extract canonical-link href values from HTML source, preserving source order and resolving no URLs implicitly.

Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.

How to use Canonical Link Extractor and understand its results

  1. Choose the URL, decoded source text, header value or explicit byte list requested by this tool. Paste the complete relevant input and follow its parsing and encoding conventions.
  2. Enter html using the field table and calculation rules, then run the tool.
  3. Read hrefs. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
htmlHTML source.string; maximum length: 1000000Required

Paste HTML. Scan link start tags, match case-insensitive whitespace-separated canonical rel tokens and collect present hrefs. Decode supported references, retaining source order, duplicates and relative strings. No matching link gives an empty list.

hrefs=source-order link hrefs with a rel token equal to canonical

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
hrefsCanonical href references in document order.list of string; maximum length: 1000000; minimum entries: 0; maximum entries: 100000
json
{
  "input": {
    "html": "<link rel=\"alternate canonical\" href=\"/article?a=1&amp;b=2\">"
  },
  "output": {
    "hrefs": [
      "/article?a=1&b=2"
    ]
  }
}

Limitations and assumptions

No URL is resolved or fetched, and the tool does not choose a canonical winner or predict search-engine behavior. HTTP Link headers and script-generated tags are not inspected.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use Meta Tag Parser: Extract named meta entries from HTML source in document order, preserving repeated keys. For a complementary task, use URL Is Relative: Check whether a reference needs a base URL and resolves against a hierarchical HTTPS base.

References

  1. Canonical Link Extractor — tool.io

Similar or alternative tools

  • Meta Tag Parser

    Extract named meta entries from HTML source in document order, preserving repeated keys.

  • URL Is Relative

    Check whether a reference needs a base URL and resolves against a hierarchical HTTPS base.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies