content icon indicating copy to clipboard operation
content copied to clipboard

Clean _redirects.txt file: update external broken links

Open OnkarRuikar opened this issue 3 years ago • 6 comments

The PR removes from-to pairs where:

  • to link is external and it is broken (HTTP 404 etc.)
  • from link isn't used anywhere in the content

I've written following simple shell script to find the broken links:

#!/usr/bin/env bash

# The script finds broken external URLs in the _redirects.txt

function check() {
    wget --spider -q -O /dev/null -o /dev/null "$1"
    if [[ $? -ne 0 ]]; then
  	    echo -ne '\r      \r'; echo $1
    else
        echo -ne '\r      \r'; echo -n $2
    fi
}

count=0
urls=( $( grep -oP 'https://.*$' files/en-us/_redirects.txt ) )
echo "Total ${#urls[@]} URLs to verify."

for url in ${urls[@]}; do
    ((count++))
    check $url $count
done

echo -e '\ndone!'

We can commit the script under https://github.com/mdn/content/tree/main/scripts and use it in daily lint cron automation.

OnkarRuikar avatar Nov 04 '22 06:11 OnkarRuikar

It looks like a lot of these have been moved:

  • From https://firefox-source-docs.mozilla.org/devtools-user/performance/
  • to https://profiler.firefox.com/docs/#/

bsmth avatar Nov 04 '22 11:11 bsmth

Hey @OnkarRuikar - thanks for this but can we hold off on this change. It looks like the docs have been moved (again) and to reduce us receiving issues about the 404, we should redirect to the new location 👍

Rumyra avatar Nov 04 '22 11:11 Rumyra

@Rumyra

to reduce us receiving issues about the 404

These redirects are not being used anywhere in the content, so this change won't create any issue in any content page.

Regarding direct use of these redirects on Internet, these have been broken for a long time now. How long we keep redirecting the non content locations?

we should redirect to the new location 👍

The new profiler is not going to have same features or documentation, e.g. https://github.com/firefox-devtools/profiler/issues/1104 . So we'll have to discard most of these anyway.🤔

OnkarRuikar avatar Nov 04 '22 13:11 OnkarRuikar

Thanks both :) I think what I wanted to avoid was folks coming and asking where these docs were, as we had to deal with a huge amount of that last year (when moved to firefox docs) - if they haven't been working for some time and we haven't received any requests I guess it's ok 👍

Rumyra avatar Nov 04 '22 15:11 Rumyra

An alternative is to change the broken redirects to either the placeholder page or the new docs:

# All destinations https://firefox-source-docs.mozilla.org/devtools-user/performance/* 
# From                                  To
/en-US/docs/Tools/Performance/Call_Tree	https://profiler.firefox.com/docs/

Generic landing page for the new docs might be better than 404? What do you think?

bsmth avatar Nov 04 '22 15:11 bsmth

Generic landing page for the new docs might be better than 404? What do you think?

@bsmth this is better! This way we won't have to worry about finding exact replacements, and it will also save us from any restructuring on Firefox docs' side.

OnkarRuikar avatar Nov 05 '22 03:11 OnkarRuikar