Is it possible to have a relative link on Lemmy for posts and comments? I’ve been able to link to local communities with the /c/community .world
notation, but when I look at the same post on two different instances, the ID in the URL is different, so I’m not sure how to link a relative path to a post (or to a comment).
No. AFAIK relative links are only possible for communities and user accounts.
You can convert a link sometimes, by putting it into search on the instance where you want it to work. But that post or comment has to have been federated to that instance.