XF 2.3 Why is the post share link different to the post number # link

Mr Lucky

Well-known member
Th post link (#) URL contains the page number as well as the post number, but the share link URL does not.

Is there any reason for this?
 
share link basically accounts for the possibility that the post could be moved to a different thread OR its page number could change due to post deletions or a setting change like no. of posts to be shown in a thread. a link with post number and page number could not load in a lot of circumstances in future.
 
share link basically accounts for the possibility that the post could be moved to a different thread OR its page number could change due to post deletions or a setting change like no. of posts to be shown in a thread. a link with post number and page number could not load in a lot of circumstances in future.
Yes I’m aware of that but it doesn’t answer the question: the the reason for having the two different URLs? Why are they different?
 
Because the non-permalink is cheaper. The permalink doesn’t cover the page number as you said (for the reasons given above) so when you hit that link, it has to resolve the proper place then redirect you (only to then load the topic again etc), whereas if you’re on the page right now you already have that context and it’s probably good enough for short term use (for the reasons given above)
 
The server. (We tend to frame resource usage as cost, therefore using less resources to do something is cheaper.) The result advantage is that it loads faster for users using the in-page link rather than the share link because it isn’t making as many database calls and server round trips.
 
The server. (We tend to frame resource usage as cost, therefore using less resources to do something is cheaper.) The result advantage is that it loads faster for users using the in-page link rather than the share link because it isn’t making as many database calls and server round trips.

I believe you but no users know that, so the question remains, what is the reason for both slow link and fast link?
 
I’m not really sure I understand what needs more explanation.

This link has a specific purpose: https://xenforo.com/community/threa...t-to-the-post-number-link.227385/post-1720671

Its purpose is to direct the user to the correct thread, on the correct page, and scroll the page to the correct post.

Which is this link: https://xenforo.com/community/threa...-to-the-post-number-link.227385/#post-1720671 (no page number, as this is the first and only page in this thread).

The first is a "permalink" (permanent link). It will always be correct. It doesn't matter where the post is. First page, second page, last page. Third, forth or last post on the page. The permalink will find the exact current position of that post. Which is the second URL.

As a more concrete example:

This URL: https://xenforo.com/community/threa...andom-off-topic-posts-etc.225303/post-1719537

Redirects to this URL: https://xenforo.com/community/threa...f-topic-posts-etc.225303/page-25#post-1719537

Why is this important?

Because if Paul comes along and deletes 5 posts which are on page 24, the second URL will no longer redirect to the correct post on the correct page because after the posts before it are deleted, that post is no longer on page 25, it is on page 24. That's why the share page URL is called a "permalink". It never changes and will always redirect to the correct page and scroll to the correct post.

Hopefully that makes sense. If you still have questions, let's approach this from a different angle. What URLs would you expect us to use instead, and why?
 
I think the question is “why aren’t they all the same, using the permalink” which is either a minor oversight or an attempt at trying to eke out performance.
 
There is neither an oversight or a performance concern. There are two different URLs out of necessity and there is really no other viable solution.
 
Given that the permalink always works why not just use it everywhere and have just the one URL? What does the other URL give you that the permalink does not?
 
Given that the permalink always works why not just use it everywhere and have just the one URL? What does the other URL give you that the permalink does not?

That is also what I'm wondering.

Hopefully that makes sense
I have to apologise, it is not making sense.
What URLs would you expect us to use instead, and why?
I would expect just to use the URL that always works. Because I see no point in the URL that can suddenly stop working. Both of them go to the post on the current page it is on. But one of them won't always do that.
 
Thus my speculation that one of the two links has a performance component (as it does in other platforms that play the same game, and that is explicitly their rationale, and/or to mitigate per-user counts of posts per page which isn’t relevant in XF)

There must be a reason why the permalink isn’t the only link (as opposed to there being a good reason why the other link isn’t the permalink, we know that)
 
There needs to be two different types of URLs because they serve different purposes:
  1. The canonical URL (with page numbers and anchors) represents the actual structure of how content is organised and displayed in the forum - posts arranged into pages with specific post anchors on each page. This is the "real" location where users view the content.
  2. The permalink is a redirection mechanism that helps find a post's current canonical location, but it can't BE the canonical location itself - because by definition, it needs to redirect somewhere.
There has to be two different URLs because:
  • A permalink has to redirect TO something
  • That something needs to be a real location where the content exists
  • The real location is inherently based on how the content is paginated and structured
It's not at all about performance - it's about the logical necessity of having both:
  1. A permanent way to find a post (permalink)
  2. The actual location where that post exists in the paginated thread (canonical URL)
 
Given that the permalink always works why not just use it everywhere and have just the one URL?
The permalink (1st link) is just a redirect so without a target (2nd link):
Where should it redirect to, nowhere? :)

Those two links are required (if you want permalinks), there is no way to have only one.

Yes I’m aware of that but it doesn’t answer the question: the the reason for having the two different URLs? Why are they different?
A post does not have a page on it's own (in XenForo), a post is always part of a thread.
So the only way to have an indexable link for a post is a canonical link to the thread page the post is currently on.

There are three different ways to reference your post:

https://xenforo.com/community/threa...t-to-the-post-number-link.227385/post-1720656
This is the URL you get when you copy the link from #4.

It includes the thread URL and the post id and gives the post ID precedence over the thread ID.
As long as the post ID exists it will redirect to the current canonial thread page URL + anchor for the post (if accessible by the visitor)
If the post does not exist any longer it will redirect to the canonical URL of the thread (if accessible by the visitor).

Using this URL is useful when you want to reference a certain post in a thread but still want to keep a reference to the thread in case the post is gone (for whatever reason).

This URL cannot be indexed (as it is only a redirect).

https://xenforo.com/community/posts/1720656
This is the permalink URL for this post.
It will always redirect to the canonical thread page URL + anchor for this post as long as the post exists (and is accessible for the visitor).
If the does not exist (any longer) it will generate a 404.
The link does not contain any reference to the thread so if the post is gone no context can be gathered from the link.

This URL cannot be indexed (as it is only a redirect).

https://xenforo.com/community/threa...-to-the-post-number-link.227385/#post-1720656
This is the canonical link for this thread with an anchor to your post, it is also the correct current link to the post.
If the post is gone (or moved to another thread) the link will still work for the thread, but the anchor will not (eg. the page will just start from the beginning).

This URL (without the anchor) can be indexed (if it is publically available).

=> Different URLs with different behaviour for different usecases.
 
Last edited:
You don’t have to make the target a link, it’s always been possible to make a link anchor that isn’t a link (the href on an a tag is not mandatory), so actually you could.

In fact, SMF 2.1 does this. The timestamp on a message in SMF link is a permalink - there’s no second link there. The # reply number isn’t a link, but the anchor for the whole post is still absolutely targetable. The only share link you see is in the form index.php?msg=123 - and it redirects you to index.php?topic=1.20#msg123 but this isn’t a visible link on the page, and it still works by way of the anchors being present.

So, the question does actually still stand: why are both links exposed to the end user when you positively don’t have to? Unless we’re getting to a place where I’m smarter than the XF dev team (I mean, it’s possible, but let’s be real, it’s pretty unlikely) :P
 
Back
Top Bottom