I'm diving into building my portfolio seriously and trying to figure out how to manage my links better. I thought about defining links in PHP at the top of my page, like this: `$mylink = haha_dot_com;` and using it in the HTML as `<a href="<?= $mylink ?>">descriptive text</a>`. Then I realized I was repeating the same link across different pages, which made me consider creating a central repository in JSON. It would have entries like `{"internal_name": "$mylink", "address": "haha.com", "locations": ["page1.php", "page2.php"]}`.
I would need a script to access this and ping each link to catch any that aren't returning a 200 status. If I do hit a dead link, all I'd need to do is update that one line. Is this approach too complicated? Do people actually do this?
3 Answers
Honestly, I think you're overthinking it a bit. A lot of folks just keep it simple with direct links and check them manually now and then. But if you're enjoying the challenge, go for it!
This might be a bit over-engineered, but if it's fun for you and you're learning, then I say go for it!
Yep, I'm definitely enjoying the learning process!
I actually did something similar years ago but used a database instead of JSON. It had a column just for link status, which really simplified tracking them.
Yeah, I’m considering the database too since my setup is already database-oriented. A status column sounds smart for monitoring!
I second that! Just keep it simple unless you really need that level of detail.