Closed spacegears closed 8 months ago
Hi there,
I absolutely love this forum software, simple and lightweight, well done and thanks for making it available to everyone.
Pretty much the only feature I really miss is SEO-friendly URLs. Is that planned to be implemented or was that intentionally left out? What I mean is going with
/user/tormater-yak
instead of/user/5
or/category/general
instead of/category/1
, or something along these lines. Also, it would be nice to include the title of a thread in the URL.If you could please consider adding this in the future (even if it's optional), that would be very much appreciated.
Thanks in advance.
This should be possible to implement, but I think one flaw of the design that you've posted is that category names, user names, and thread titles are all dynamic, meaning there would have to be some indicator in the URL as to what category, user, or thread it really points to, and it would also be much easier to implement with the way a lot of the code expects numeric values in these arguments. So one thing that could be done is URLs like /user/5/tormater-yak
or /category/1/general
or /thread/155/sample-thread
which is something I'll definitely look into implementing, so let me know what you think about that format of URLs, and also, thanks for using Tormater Forum.
Additionally, one thing to note here is the term "SEO-friendly" is a misnomer, as search crawlers can very much crawl the kinds of URLs that Tormater uses. The correct term in this case would be "Human readable". (So, in the rare case that you're looking to make your site crawl better this way, it won't actually help.)
Well, I'm not a programmer, so I could be dead wrong here, but usernames and category names should be unique values, so I don't think a numerical identifier should be mandatory in those cases. It also looks nicer without the numbers in those URLs. Then again, if you say the code expects numerical values there, you're probably not going to rewrite everything - just because it looks nicer. I could definitely live with those examples you just mentioned.
As for the URL for a thread, I think something like /thread/155/sample-thread
is exactly how many other forum software are handling it by the way.
I don't really like the term "SEO-friendly" and wanted to go with the word "slug", but I hate that one, too. And you're absolutely right... Human readable it is. :)
Thanks for considering this additional feature.
Well, I'm not a programmer, so I could be dead wrong here, but usernames and category names should be unique values, so I don't think a numerical identifier should be mandatory in those cases. It also looks nicer without the numbers in those URLs. Then again, if you say the code expects numerical values there, you're probably not going to rewrite everything - just because it looks nicer. I could definitely live with those examples you just mentioned.
Right, they're unique, so technically speaking, you could use them, but they're not static, so if someone links to /user/tormater-yak
but their username is now /user/tormater-yak-2
, then they're going to hit a 404 page. And this also applies to categories.
But that's semi-solvable with redirects, the main issue is simply that it would be quite a lot of work to change the way every page reads from the database.
@spacegears I've made an extension to handle URL slugs. Let me know what you think, or if you encounter any issues with it. https://github.com/tormater-yak/slug-urls
@spacegears I've made an extension to handle URL slugs. Let me know what you think, or if you encounter any issues with it. https://github.com/tormater-yak/slug-urls
Wow, that was quick, thank you very much. The /user/
part is perfect.
The /category/
and /thread/
parts work great, too, there's only one thing I couldn't figure out: why is the forced /1/
necessary in those URLs? I'm sure there's a good reason for it, and I've also checked the code and found the relevant part... I still don't get it. I just wish there was a way to leave that out. Again, I'm not a programmer, I'm sorry if the answer is very obvious.
Note: The requirements for the forum say "PHP 7.4+" (that's what my host has) but the function fetch_column()
that you're using in this extension.php
was added in PHP 8.1. Same goes for str_contains()
in /libs/templates.php
, that function requires PHP 8. I was able to add a workaround in both cases, but I though I would let you know.
@spacegears I've made an extension to handle URL slugs. Let me know what you think, or if you encounter any issues with it. https://github.com/tormater-yak/slug-urls
Wow, that was quick, thank you very much. The
/user/
part is perfect.The
/category/
and/thread/
parts work great, too, there's only one thing I couldn't figure out: why is the forced/1/
necessary in those URLs? I'm sure there's a good reason for it, and I've also checked the code and found the relevant part... I still don't get it. I just wish there was a way to leave that out. Again, I'm not a programmer, I'm sorry if the answer is very obvious.
The second number is for the current page you're on. I specifically included those in-case the thread's slug is something like "3" which, in practice, would turn the URL into thread/13/1/3 which goes to the first page with 1 for the slug, instead of thread/13/3 which goes to the third page.
However, I seem to have accidentally put an OR where there should be an AND, so the fix should only apply to numeric slugs.
Note: The requirements for the forum say "PHP 7.4+" (that's what my host has) but the function
fetch_column()
that you're using in thisextension.php
was added in PHP 8.1. Same goes forstr_contains()
in/libs/templates.php
, that function requires PHP 8. I was able to add a workaround in both cases, but I though I would let you know.
Oh, sorry about that. I'll go ahead and fix that right away.
@spacegears I've made an extension to handle URL slugs. Let me know what you think, or if you encounter any issues with it. https://github.com/tormater-yak/slug-urls
Wow, that was quick, thank you very much. The
/user/
part is perfect. The/category/
and/thread/
parts work great, too, there's only one thing I couldn't figure out: why is the forced/1/
necessary in those URLs? I'm sure there's a good reason for it, and I've also checked the code and found the relevant part... I still don't get it. I just wish there was a way to leave that out. Again, I'm not a programmer, I'm sorry if the answer is very obvious.The second number is for the current page you're on. I specifically included those in-case the thread's slug is something like "3" which, in practice, would turn the URL into thread/13/1/3 which goes to the first page with 1 for the slug, instead of thread/13/3 which goes to the third page.
However, I seem to have accidentally put an OR where there should be an AND, so the fix should only apply to numeric slugs.
Note: The requirements for the forum say "PHP 7.4+" (that's what my host has) but the function
fetch_column()
that you're using in thisextension.php
was added in PHP 8.1. Same goes forstr_contains()
in/libs/templates.php
, that function requires PHP 8. I was able to add a workaround in both cases, but I though I would let you know.Oh, sorry about that. I'll go ahead and fix that right away.
Oh, right, the page. I'm already quite happy with this extension, but if I could have one last modification request, that would make it perfect.. although it would require a different approach I think, so it might be too much: what if the page parameter (?) would be at the end of the URL? For example, for the first page, it could be emitted (/thread/10/thread-title
), but for every other page it could be like /thread/10/thread-title/p2
or /thread/10/thread-title/page-2
. Would this be possible?
Also, one additional thing I've noticed - even with your updated code from yesterday: If you open a thread that has at least 2 pages, the page navigator menu isn't quite right. The URLs for page numbers do not include the slug at the end, while the left/right arrows do.
To sum things up, if you could please consider that new approach described above, that would be much appreciated, if not, that's fine... this extension is already way better than the default URLs without the slug.
Oh, right, the page. I'm already quite happy with this extension, but if I could have one last modification request, that would make it perfect.. although it would require a different approach I think, so it might be too much: what if the page parameter (?) would be at the end of the URL? For example, for the first page, it could be emitted (
/thread/10/thread-title
), but for every other page it could be like/thread/10/thread-title/p2
or/thread/10/thread-title/page-2
. Would this be possible?
This is something that can't really be done in an extension like this, but it would be better if it was possible.
Also, one additional thing I've noticed - even with your updated code from yesterday: If you open a thread that has at least 2 pages, the page navigator menu isn't quite right. The URLs for page numbers do not include the slug at the end, while the left/right arrows do.
This is a weird bug and it shouldn't be occurring. I'll have a look at the main software's implementation of the page navigator and see if that's the cause.
Hi there,
I absolutely love this forum software, simple and lightweight, well done and thanks for making it available to everyone.
Pretty much the only feature I really miss is SEO-friendly URLs. Is that planned to be implemented or was that intentionally left out? What I mean is going with
/user/tormater-yak
instead of/user/5
or/category/general
instead of/category/1
, or something along these lines. Also, it would be nice to include the title of a thread in the URL.If you could please consider adding this in the future (even if it's optional), that would be very much appreciated.
Thanks in advance.