Answers.Body: <p>It was clearly documented on <a href="https://twig.symfony.com/doc/2.x/filters/url_encode.html" rel="nofollow noreferrer">Twig Official Documentation</a> that we can use <code>url_encode</code> filter to convert it to url friendly string.</p>
  
  <p><strong>Example</strong></p>
  
  <pre><code>{{ "path-seg*ment"|url_encode }}
  {# outputs "path-seg%2Ament" #}
  
  {{ "string with spaces"|url_encode }}
  {# outputs "string%20with%20spaces" #}
  
  {{ {'param': 'value', 'foo': 'bar'}|url_encode }}
  {# outputs "param=value&amp;foo=bar" #}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-16T18:01:45.970Z
Answers.LastActivityDate: 2017-08-16T18:01:45.970Z
Answers.UserDisplayName: Jefry Dewangga
Answers.Body: <p>I was about to ask this question, but realized that it's closely related to <strong><a href="https://craftcms.stackexchange.com/questions/184/is-it-possible-to-convert-string-to-uppercase">this question</a></strong>.</p>
  
  <p>The answer, like in the above referenced question <a href="http://twig.sensiolabs.org/doc/filters/index.html" rel="noreferrer">lies with Twig filters</a>.</p>
  
  <p>Specifically, in this case, one needs to use the <a href="http://twig.sensiolabs.org/doc/filters/url_encode.html" rel="noreferrer"><code>url_encode</code></a> filter to convert the text needed.</p>
  
  <p><strong>Example</strong></p>
  
  <pre><code>&lt;a href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}&amp;source=Xavier%20Creative%20House&amp;summary={{ entry.question|url_encode|striptags }}" target="_blank"&gt;
  </code></pre>
  
  <p>In any case, I hope that helps others with this. I know how easy it is to forget that the answers sometimes like over in the Twig docs, and not Craft’s.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-14T22:35:05.907Z
Answers.LastActivityDate: 2014-07-14T22:35:05.907Z
Answers.LastEditDate: 2017-04-13T12:51:00.200Z
Answers.UserDisplayName: Christopher Kennedy-Nuñez
Body: <p>If I want to convert text into a URL friendly string for sharing text in a social media link, how would I go about that?</p>
  
Tags: <templating><url><string><conversion>
Title: How can I convert text into a URL-friendly string?
ThreadText: # How can I convert text into a URL-friendly string?
  
  (Asked by: username_0 on 2014-07-14)
  
  If I want to convert text into a URL friendly string for sharing text in a social media link, how would I go about that?
  
  **Tags:** templating, url, string, conversion
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2014-07-14. Score: 13 | Accepted answer
  
  I was about to ask this question, but realized that it's closely related to **[this question](https://craftcms.stackexchange.com/questions/184/is-it-possible-to-convert-string-to-uppercase)**.
  
  The answer, like in the above referenced question [lies with Twig filters](http://twig.sensiolabs.org/doc/filters/index.html).
  
  Specifically, in this case, one needs to use the [`url_encode`](http://twig.sensiolabs.org/doc/filters/url_encode.html) filter to convert the text needed.
  
  **Example**
  
  ```
  <a href="http://www.linkedin.com/shareArticle?mini=true&url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}&source=Xavier%20Creative%20House&summary={{ entry.question|url_encode|striptags }}" target="_blank">
  
  ```
  
  In any case, I hope that helps others with this. I know how easy it is to forget that the answers sometimes like over in the Twig docs, and not Craft’s.
  
  
  ---
  
  ### Answer by username_1 on 2017-08-16. Score: 1
  
  It was clearly documented on [Twig Official Documentation](https://twig.symfony.com/doc/2.x/filters/url_encode.html) that we can use `url_encode` filter to convert it to url friendly string.
  
  **Example**
  
  ```
  {{ "path-seg*ment"|url_encode }}
  {# outputs "path-seg%2Ament" #}
  
  {{ "string with spaces"|url_encode }}
  {# outputs "string%20with%20spaces" #}
  
  {{ {'param': 'value', 'foo': 'bar'}|url_encode }}
  {# outputs "param=value&foo=bar" #}
  
  ```
  
  
  ---
  
  