I hit the same problem recently. My solution was very similar to what Adam proposed: build the same ref again (completely) and calculate the hash. Since in rowiki all interaction with Wikidata is through modules, it was trivial to extract the reference code and invoke it directly or from a template.

One nasty problem that I couldn't really solve nicely was that the CS1 module would add a templatestyle which on subst would be expanded to a different strip marker for each instance, causing "reference with same name and different content" errors. This meant I could use a template, but not substitute it. If I understand your use case correctly, you won't have this problem.

When this feature becomes available, you could simply adapt the template to generate the <ref extends> tag.

Hth,
 Strainu

Pe miercuri, 21 august 2024, Adam Wight <adam.wight@wikimedia.de> a scris:
> Hi, I'm one of the developers working on this project.
> Thanks for the question!  Currently, the state of our thinking around reusing refs from a template is that it's problematic, but the simplest and safest existing workaround is to produce another ref in exactly the same way as the first.  So if the CS1 family of templates is used (eg. Cite book / Literatur) then you can use the same or a similar template to generate the second ref, and if the parameters to CS1 match then your final refs will be identical and the footnote markers will be merged together into one symbol and one reflist item.
> The second possibility would require a feature change which has some questionable implications: that any two refs with identical content could be merged in reading mode, regardless of the "name" attribute.  However, since the reference content can only be guaranteed to be identical if the same template is used, I believe the first solution (use the same underlying template and let it produce a name) is the best workaround for the moment.
> Please do suggest any better ideas you might have...  so far, it's been hard to imagine what a more "stable link" might look like, maybe it's an explicit "cid" or HTML id, we're really not sure yet.
> Regards,
> [[mw:User:Adamw]]
>
> On Tue, Aug 20, 2024 at 10:47 AM Bináris <wikiposta@gmail.com> wrote:
>>
>> I have just experienced a related problem recently. I am not sure if it is in the scope of your project, so I just mention it here.
>> Original problem: a reference is given in Wikidata as source of death, for example. It appears automatically in infobox.
>> Later in the article I need that for another purpose, and it will appear on tha pege twice.
>> Question: can we make it appear once?
>> Answer in huwiki: the link of Wikidata contains a hash, which can be used as <ref name="this-hash"/>.
>> New problem: whenever the source is edited in Wikidata, the hash regenerates, and the article will silently be spoiled. We can discover the error in ref name only accidentlly, and it is a head ache to guess the original.
>> Relation to this project: can we safely reuse the references originating from Wikidata? Can it offer a stable link?
>> Or should I write this to Wikidata mailing list?
>> _______________________________________________
>> Wikitech-l mailing list -- wikitech-l@lists.wikimedia.org
>> To unsubscribe send an email to wikitech-l-leave@lists.wikimedia.org
>> https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/
>
> --
> Adam Wight - Developer - Wikimedia Deutschland e.V. - https://wikimedia.de
>