Avoiding Dead Links
I am finally getting serious about building out my portfolio.
I was adding a link to one of my pages and realized it would be a bit easier if I defined it in PHP up top: `$mylink = haha_dot_com;` then in the page, `<a href="<?= $mylink ?>">descriptive text</a>`.
Then I realized I was putting the same link into two different pages. Why not have a central repository, perhaps in `JSON`? So, a record could look like `{"internal_name": "$mylink", "address": "haha.com", "locations": ["page1.php", "page2.php"]}`.
A little access script would be required. If the records were in a database, it would be something like `$mylink = $cms->get_links()->get_link("$mylink");` when the page loads.
Then, write a little script to step through those records and ping every address. Anything that's not a 200 gets put on an exception report. For those on the report, an easy fix is just updating the one line. If the break is worse than finding a new URL, there would be record of where the dead links are.
Overkill? Does anyone actually do this sort of thing?