Find and Fix Broken Links in AEM

Avatar

Avatar

snbaem

Avatar

snbaem

snbaem

10-12-2020

Hello All,

 

Probably bringing back one of the previously asked questions about finding and fixing broken links in AEM. There are some discussions and solutions mentioned eg using groovy script (can't use this currently) and link checker (https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/broken-link-scan/qaq-p/220... and some discussions about disabling link checker because of possible performance issues.

 

I tried using the linkchecker tool in AEM 6.5 and it was showing a couple external links that I authored incorrectly but not the internal link that was authored incorrectly. Still with the incorrect external links we can't right away find where it has been used but we can do  query I suppose (involving devs)

 

https://www.tadigital.com/insights/perspectives/identify-and-fix-broken-links-aem-link-checker and https://www.tadigital.com/exchange/link-checker/ looks very promising but I am not sure how it is implemented.

 

Please suggest for following thoughts or any other ideas.

- Periodically, in author go through all nodes (their properties) and check for the authored links and hrefs. Get the paths with broken links or a map of broken link --> affected paths and save it. Add to this a component may be where we can input path/path tree , broken link, updated link

- Keep link checker on in author and utilize etc/linkchecker tool to get the broken links and query the broken links. For broken internal links think of something else

 

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

BrianKasingli

MVP

Avatar

BrianKasingli

MVP

BrianKasingli
MVP

11-12-2020

@snbaem,

This is another idea.

If you have nodeJS installed on your machine, there's a tool that I personally use to scrape through an entire website, checking if there are any broken links. If there are any broken links, you should be able to see the highlighted under-tested page, and which link is broken.

https://www.npmjs.com/package/broken-link-checker

The tool is great, you provide it with the root level of the website, and it will keep traversing down the links from the website, and output results. 

 

The example bellow is reporting generated from https://photoshop.com/en: 

BrianKasingli_0-1607686453703.png

Once you download the node plugin, you can simply run something like:

blc https://photoshop.com/en -ro

 

Answers (1)

Answers (1)

Avatar

Avatar

shelly-goel

MVP

Avatar

shelly-goel

MVP

shelly-goel
MVP

11-12-2020

@snbaem  The linkchecker is mostly used to check the external links and does have performance impacts. Moreover it would just check the link but fixing it, is manual. As per your requirement where you need to find the broken link and need a way to update it as well, I would suggest to use sling rewriter pipeline.

Sling provides a way to rewrite the output/generated markup of a page via a pipeline feature and it is activated in AEM by default (used for the AEM-built in link checker and link rewriting features as well). You would have to create a new transformer-type with all the logic that you need to fix the broken link and add it to the rewrite configuration.

Code Examples:

https://helpx.adobe.com/experience-manager/using/aem63_link_rewriter.html#AddJavafilestotheMavenproj...

https://www.flexibledesigns.rs/creating-a-link-rewriter/

http://www.wemblog.com/2011/08/how-to-remove-html-extension-from-url.html