Manual:$wgExternalInterwikiFragmentMode

Details
See documentation for above for details of each mode. Because you can't control external sites, this setting should probably always be 'legacy', unless every wiki you link to has converted to 'html5'.