Creating links to content

How to link to resources located inside and outside the site.

Linking to other documents and folders is easy in a Plone site. The syntax you will use to create the link depends upon whether you are using the default editor or the visual editor.

This applies to most content types, such as Documents, Events or News Items, where you can enter free text. If you simply wish to create a content object which links to an internal or external resource, you can use the Link content type.

Visual Editor

If you are using the visual editor, you can to create a link as follows: highlight the text that you would like to have linked, and then click on the link icon in the toolbar of the visual editor window (it looks like a couple of chain links). Then, if the object you are linking to is inside the site, you can browse to it using the popup window that appears. If the object is outside the site, you can type in the URL or file location.

Use this syntax to point to a web address :

      http://www.foo.com

 

Linking to an email address is simple, too. Simply type in the phrase "mailto:" followed by the email address you would like to link to. For example :

      mailto:someone@foo.com

 

Default Editor

If you are using the default editor, then you have the option of using "structured text" formatting or HTML formatting. (Plain text is also an option, but you can't make links in plain text, so it wouldn't be a good one to choose in this case.)

Structured Text

To create a link in structured text, simply put the link phrase in quotes, follow it by a colon and follow that with the address of the object you are linking to.

For example, typing this :

        "Some Web Address":http://www.foo.com

 

Will get you this:

Some Web Address

To make an internal link to a resource on your own site, just use the path to the resource instead of a web address. For example, if you have a document called ContactUs in the about folder of your plone site, then typing this :

         "Click here to contact us":/about/ContactUs

 

will get you this:

Click here to contact us

If you supply only the short name, instead of the path, Plone will generate a relative link. In the above case, this means :

      "Click here to contact us":ContactUs

 

This comes out as follows:

Click here to contact us

Look closely at the URL that link points to, and you'll see the difference. Note that as long as the ContactUs page is in a parent folder of the current page, the link will still work, as Zope finds the resource using the mechanism of acquisition .

HTML

To create the same link in HTML would look like this :

        <a href="http://www.foo.com">Some Web Address</a>

 

Of course, since the text format you choose affects the entire document, if you want to use HTML for your links, you will also need to create the rest of your page in HTML. Likewise, if you use structured text for your links, you will also need to pay attention to structured text rules for the rest of your document. (If you insist, you can mix HTML in with your structured text, but don't be surprized if this makes it harder to edit later on.)

reStructuredText

In reStructuredText, the named link would have to be created like this:

     This is `Some Web Address`_ in my text.

     .. _`Some Web Address`: http://www.foo.com

 

That's nice if you want to refer to Some Web Address many times in the course of a document. If it's just a once-off link, it's quicker to write:

    `Some Web Address <http://www.foo.com>`_

 

Open a Link in a New Window

It's a common request to want a link to open in a new window.

You can do this in HTML by formating your link like this:

<a href="http://blah.blah.org" target="_blank">Link text</a>