We have an Article that a link field, field_link. When we create a new page of type Article, we set the link field to have a URL of www.example.com/somepath?someid=123345 and label of View. When the page is rendered, we are seeing the query parameter is being removed (i.e. ?someid=123345). We are not doing any hooks or extra logic in twig templates to remove the query parameters.

How can we prevent the query parameters from being removed when rendering the field_link field?

Current behavior when link is rendered:

<a href="www.example.com/somepath">View</a>

Expected behavior

<a href="www.example.com/somepath?someid=123345">View</a>
  • 1
    which config you set to your link field, Both internal and external links ? i tested it it works.
    – berramou
    Feb 7 '19 at 23:19
  • I feel like the link fields want a scheme for external urls, e.g. https://
    – sonfd
    Feb 7 '19 at 23:40
  • @berramou that setting is what was missing. Feb 11 '19 at 16:58
  • Great, so it working now ?
    – berramou
    Feb 11 '19 at 16:58
  • @berramou yes, i also had to add https:// Feb 11 '19 at 17:22

In review, we had the wrong setting for the link. By setting Both internal and external links, the link was displaying properly with the query parameters.

In Summary

  1. Both internal and external links should be set on the field setting
  2. Ensure to use https:// in the beginning of the url

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.