Link Auditor And Fixer
Find and fix broken or insecure links across an entire site, including CMS content, to improve SEO and user experience.
Prompt
How it works
Crawling and Link Extraction (Read Phase - Data API)
- Pages: Get all pages with
pages_list. For each page, get its content usingpages_get_content. Parse the content to find all link elements, their URLs, and their unique node IDs. Store the mapping:{pageId, nodeId, url, linkText}for each link found. Note: Links may appear astype: 'text'nodes with HTML containing<a>tags, or astype: 'Link'elements. The nodeidfield from the Data API can be used directly in Designer tools. - CMS: Get all collections with
collections_list. For each collection, get all items usingcollections_items_list_items. For each item, iterate through its fields and parse any rich text content to find links.
Validation
For each unique link found, make a network request to check its status.
If a link returns a 4xx or 5xx status code, it’s “broken” and flagged for manual review.
If a link starts with http://, try the https:// version. If the HTTPS version works, the link is “insecure” and a fix will be proposed. If the HTTPS version fails, it is flagged for manual review.
Planning (Dry Run)
Compile a list of all proposed changes (e.g., “On the ‘About Us’ page, change http://example.com to https://example.com”).
Compile a separate list for links that need manual review.
Present both lists to the user for approval.
Execution (Write Phase - Designer & Data APIs)
- Pages: For links on static pages that need fixing:
- Use
de_page_toolwithswitch_pageaction to navigate to the target page (use thepageIdfrom the crawling phase). - Use
element_toolwithselect_elementaction, passing the ID object:{component: pageId, element: nodeId}wherepageIdis the page ID andnodeIdis the node ID extracted from the Data API. - Use
element_toolwithset_linkaction on the selected element, passinglinkType(e.g., ‘url’, ‘page’, ‘email’) andlink(the corrected URL or target).
- Use
- CMS: For links in CMS items, use
collections_items_update_items_liveto update the rich text field with the corrected link.