Use relative paths for internal links of any Drupal website: How to create internal links in Drupal 7

If your website is build on Drupal CMS, then you may need sometimes to link your contents to other contents. For example, you are creating a content about online Drupal web hosing and you would like to link with some other internal contents of your website. What do you do? The general scenario is that you use full path name for this type of linking. But for Drupal, if you would do this then the link may not work always. Suppose, you change the website domain name, so what would be the internal linking? In this situation, the internal linking of full paths will not working. For this type of situation i.e. when you need to link internal contents, you need to use relative paths for internal linking. This page tells you the details about internal linking of your website contents which would always work even the domain name changing or something like this.

How to create internal links in Drupal 7?

At the time of creating links from one pages of your website site to another page website contents, never use the full path. Wee need to use paths that must begin with a "/" slash, not with the domain name. Doing this way, has a great benefit always. If you ever change the website domain name within Drupal hosting account or export your site and republish it under a new URL, this kind of link still work. So, the website internal links are always active and working whatever the change occurred. To do this, the format of the links will look like the following:

<a href="/path-of-the-content-to-link">some text about the link content</a>

When we follow the above method, Drupal will automatically add the domain URL to this kind of path:

<a href="/path-of-the-content-to-link">some text about the link content</a>

For example, we have a content with the following information:

Content Title: Quickly register domain name! Why do you need a domain name?
Content URL: http://www.hidemytips.com/content/quickly-register-domain-name-why-do-you-need-domain-name

So, to create an internal link, we have to delete the domain name part and write the following code:

<a href="/content/quickly-register-domain-name-why-do-you-need-domain-name">Quickly register domain name! Why do you need a domain name?</a>

And that's all. Creating all internal links in this way, helps the link always fresh and active whatever the domain name change or not.

More by this Author


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working