In Magento 2 product page I need to add a link beside the Size attribute, should show as below image.
which xml and phtml file to edit?
There are several ways to do this, one of the easiest way is to create .phtml file and put all the contents or create block and get data from database into the phtml. Location of your .phtml can either be inside your extention view/frontend/template/product/view/* folder or inside your theme in the same hierarchy.
Once done, then in your theme/extension layout
catalog_product_view.xml layout file, you can inject your block and phtml file
<referenceContainer name="yourconteinername"> <block class="YourbockClass" name="product_view_link" after="-" template="YourModule::product/view/yourtemplatefile.phtml"/> </referenceContainer>
also you can use move needle in the layout xml to show this block whereever you may want
<move element="yourconteinername" destination="product.info.main" before="-"/>