Answers.Body: <p>A good approach would be to use the <code>UrlHelper</code> <a href="https://docs.craftcms.com/api/v3/craft-helpers-urlhelper.html" rel="nofollow noreferrer">class</a> it has a function <a href="https://docs.craftcms.com/api/v3/craft-helpers-urlhelper.html#method-url" rel="nofollow noreferrer">UrlHelper::url()</a> that is available in Twig and will return the correct URL for a certain path. So you could ask your client to not insert the entire URL, only the path -&gt; instead of <code>example.com/entries</code> -&gt; <code>entries</code> or you can include a custom Twig function/behavior that strips the domain before you use the <code>{{ url('entries') }}</code> function.</p>
  <p>Anyway: to be honest I would create a different approach in the first place. Creating static URLs in a text field is usually not a good thing. I'm always a fan of the</p>
  <blockquote>
  <p>protect clients against themselves</p>
  </blockquote>
  <p>philosophy so you may want to consider to create a custom field type with autosuggestion or something. SEO wise it could be a bad idea if you clients are able to insert whatever they want and you output too many dead links. Maybe a Relation field could be something for you?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-03T10:24:35.620Z
Answers.Text: So I actually went with your suggestion of just having the client put in the slug of the url. Inside my template I just append the siteUrl onto the front of it. It seems to work across three different languages.
Answers.UserDisplayName: Dan Zuzevich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-28T17:18:24.253Z
Answers.LastActivityDate: 2018-06-28T17:18:24.253Z
Answers.LastEditDate: 2020-06-17T08:56:27.903Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I was wondering if it was possible to use an alias inside a field in the Admin panel. For example, I have a global section called "Navigation" which contains a matrix called "Links". This matrix allows the client to create links for their navigation bar. Inside each matrix block, is a field called "Link Url" where the client can put in a link.</p>
  
  <p>Right now the client is hardcoding urls for the production site, so my links don't work on my dev environment. I would like to rectify this, with some type of elegant solution.</p>
  
  <p>Any ideas?</p>
  
Tags: <admin>
Title: Using Aliases inside Admin Panel for fields
ThreadText: # Using Aliases inside Admin Panel for fields
  
  (Asked by: username_0 on 2018-06-28)
  
  I was wondering if it was possible to use an alias inside a field in the Admin panel. For example, I have a global section called "Navigation" which contains a matrix called "Links". This matrix allows the client to create links for their navigation bar. Inside each matrix block, is a field called "Link Url" where the client can put in a link.
  
  Right now the client is hardcoding urls for the production site, so my links don't work on my dev environment. I would like to rectify this, with some type of elegant solution.
  
  Any ideas?
  
  **Tags:** admin
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-28. Score: 1 | Accepted answer
  
  A good approach would be to use the `UrlHelper` [class](https://docs.craftcms.com/api/v3/craft-helpers-urlhelper.html) it has a function [UrlHelper::url()](https://docs.craftcms.com/api/v3/craft-helpers-urlhelper.html#method-url) that is available in Twig and will return the correct URL for a certain path. So you could ask your client to not insert the entire URL, only the path -> instead of `example.com/entries` -> `entries` or you can include a custom Twig function/behavior that strips the domain before you use the `{{ url('entries') }}` function.
  
  Anyway: to be honest I would create a different approach in the first place. Creating static URLs in a text field is usually not a good thing. I'm always a fan of the
  
  > protect clients against themselves
  
  philosophy so you may want to consider to create a custom field type with autosuggestion or something. SEO wise it could be a bad idea if you clients are able to insert whatever they want and you output too many dead links. Maybe a Relation field could be something for you?
  
  > **Comments:**
  > **username_0**: So I actually went with your suggestion of just having the client put in the slug of the url. Inside my template I just append the siteUrl onto the front of it. It seems to work across three different languages.  
  
  ---
  
  