The Link field is used for adding links to the web, to documents in your Prismic repository, or to files in your Prismic media library. 

There are three types of links:

  • Link to an external URL
  • Link to another document in the current Prismic repository.
  • Link to a file in your media library, which can be any kind of file (like a PDF, image, or audio file for instance)

By default a Link field will allow an author to select any of these options. If you wish to restrict an author to only select another document, use the Content Relationship field. If you wish the author to only select a media item, use the Link to Media field.

 

Configuration

Assign the Link field a Field name, API ID, and Field placeholder that will display in the entry editor. You can also click the checkbox which will allow authors to select that a given link will open in a new tab.

JSON Configuration

You can configure the link field to only allow an author to select a Link to the Web. Refer to the examples below to see how to add this configuration.

 

JSON Editor

The following is a link to anything (external URL, internal content, or media library file):

"link": {
  "type": "Link",
  "config": {
    "label": "Link to Anything",
    "placeholder": "Link to anything..."
  }
}

 
The following is a link only to an external URL and it allows the author to select the "Open in a new tab" option:

"weblink": {
  "type": "Link",
  "config": {
    "label": "Link to the Web",
    "placeholder": "Add a link to the web",
    "select": "web",
    "allowTargetBlank" : true
  }
}

 

JSON Reference 

"type": (string, required) Value must equal "Link"

"config": (object, optional) Options listed below

 

config

"label": (string) Sets the label that shows up for the field in the entry editor

"placeholder": (string) Sets a placeholder to display in the select dropdown

"select": (string) Set to "web", it restricts the link to only select a "Link to the web"

"allowTargetBlank": (boolean) If set to true, will allow an author to select the "Open in a new tab" option 

Did this answer your question?