Is there any possible way to identify broken links and fix it at the same time?
Hi Kevin
Can you define a “broken link” in your context?
Is it:
-
A link in a user’s post?
-
An internal link?
-
An external link?
-
A link that leads to a resource that doesn’t exist anymore (404)?
-
A link that doesn’t lead to the same resource it led to before?
How would you know if a link is temporarily “broken” (for example, the target is temporarily down for whatever reason)? A link can be dead for a few minutes, hours, days or weeks and come back.
It can be removed, changed, updated, relevant or irrelevant anymore. How would you know what?
What is a broken link fix?
-
A link removal?
-
Replace the URL with another one?
-
How would you know how to replace a broken link with a relevant working one?
Anyway, you would need a custom script though: there is no such built-in feature.
Not my job to answer but quite generally over all webistan a broken link is a link given 404, no matter if it is internal or external (sure, internal one is alarming situation quite often).
And a fix can be any of those.
Getting a list of 404s and then ether fix url or removing <a>
-tag perhaps? That is quite common way on all other platforms I’m using,
Is there any tool that you can suggest to use for checking and fixing broken link?
I agree that’s the most common, but it raises issues, like temporary 404s.
You’ve been here long enough to know that everyone’s opinion is valued
(my job is also letting people give their opinion btw)
Those shouldn’t use. It should be first 302 leading to (generic) url where the situation is explained and when it stops to be temporary it changes to 200, 301 or 410.
But if posts use links that gives temporary 404 that is famous edge case. Most common ones are actual outboud dead links that should fix.
Good news are those are quite rarely opened, I reckon.
Yeah Well, I ment I was kind of answering behalf of OP, and it is not so pollite act.
Well in my case broken links was caused when the client did a minor domain change from “.ai” to “.com” all message links within the forum became broken am sure there was likely an easier way to fix. But I just manually edited many posts to change the .ai to .com. Also have had to use rebuild html to fix uploaded images in posts. Quite the nuisance.
You can do search&replace via rails console, can you?
Likely but still pretty new at many thubgs with discourse. Need to read up and learn more. Would something like that fix uploaded images in posts? It also seemed to affect emojis in polder posts as well. They honestly should have talked to me about it as they rebranded the site before with the same issue arising. Imho there was no need or real benefit to change from ai to com as the site has ran for 3+ years on the .ai
Plus any user whom installed the app had become broken and the same with others using the original url yo acs the site.
There is no such feature available in Discourse and detecting “broken links” (we’ll assume 404) would require a custom script.
Seems to me there would be some number of owners, especially of larger sites, would be interested in a tool/script/plugin that could at least do the first step of simply checking for and identifying 404’s? I’d be in for supporting this with some coin if somewhat reasonable.
The first solution that comes to my mind would be a rail script that iterates through post contents, find links, requests them, checks the status code and does whatever you need. Delete them, replace them (such actions would require a rebake), log them…
WordPress vs. Discourse is quite useless comparison because tech and idea are so different, but on WordPress it is quite trivial job to use a free plugin, that calls outbound links and if response is something else than 200 OK
it cleans at least links given 4xx status, makes a list and informs admin via email.
Is that even possible on such apps as Discourse, I don’t know. Is such functionality needed… I don’t know, because nobody cares anymore and saying good links never die has changed to all links will turn to zombies. Wikipedia is full of dead links, and no one cares, not even Wikipedia nor editors.
We have such thing called as flags. We can outsource informing to users and teach them how to use flags informative way — but I bet it will be hard.
Let’s be honest. Quite few admin/moderator is willing start fixing links that is never used after publishing. So ”link tester” would be nice to have, but is it useful tool? My biggest WordPress site has tons of dead outbound links. Those should be fixed and I will if I need those, but otherwise… I just don’t have time (or will…).
A broken link checker would be great! Our instance of Discourse isn’t public, so I can’t use a typical tool for this. It’s used like a support forum and knowledgebase, so we anticipate that over time we may be dealing with links to documentation housed elsewhere that break.