Global | Classic

A Global field is a reusable field (consisting of a group of fields) that you can define once and reuse in any content type within your stack. This field saves the time and effort of adding the same set of fields (and their settings) in multiple content types of a stack.

In order to use a Global field, you need to first create a Global field, and then add it in any content type.

Additional Resource: For a flexible Global field, you can now add a Modular block within the Global field or maybe nest a Global field within a Group field.

This field possesses certain properties that you can change any time as per your needs. The properties that can be modified are “Select Global Field,” “Display Name,” “Unique ID,” “Instruction Value,” “Help Text,” “Multiple,” and “Non-localizable.”

An example of this field would be creating the SEO field. When you create an SEO global field, add and configure a few subfields (“Meta Title” and “Meta Description”) under it. Now, you can add this global field to multiple content types of your stack.

Then, while creating an entry, this SEO field will be automatically populated with the Meta Title and Meta Description subfields, as shown below:

global.png

Additional Resource: You can hide/show a field when certain conditions are met with the help of Field Visibility Rules.

To learn how you can use a field for a given scenario, we recommend you to check out our Content Modeling guide.

Editing any current field in existing Content Type might result in data loss. To prevent data loss, make sure to check out our Content Type Change Management guide.

i>

Global Field Use cases

Let's understand how we can use Global fields in our content type through the help of some real world examples.

Global field can be used for the following most common use cases:

  • SEO field as a global field
  • Address/ Site Description field as a global field
  • Taxonomy group field as a global field
  • Website Banner

Example 1: Use the Global field as a SEO field

Having an SEO field in your content type (within the entry) can enhance your search results and drive traffic to your website. By using keywords and tagging, developers can globally define an SEO field (through the global field) and use it across content types.

Lets see how we can implement and use the SEO field as a global field.

  1. Log in to your Contentstack account, open the content type module and select the Global field tab.
  2. Drag and Drop the fields you want to add in the SEO section. In Edit Properties you can define the properties of the fields. For our example we have added the following fields:
    • Multi Line Textbox : The title tag assigns name to the metadata that introduces your website.
    • Multi Line Textbox : The meta description tag contains a summary of your website’s content.
    • Multi Line Textbox : Add the keywords from your content in this field.
    • Boolean: This field will allow/ disallow this content entry to be searched within the site.
    • Boolean: This field will enable/ disable search engines to read the file to intelligently crawl your site.
  3. //screenshot
  4. The global field setup is done. Now, add this global field to your content type(s).
  5. Open the content type builder of the content type, where you want to add the SEO field. Now, drag and drop the Global Field and select SEO from the Select Global FIeld dropdown. Add a suitable Display Name and Edit Properties accordingly.

Example 2: Address/Site Description Field as a Global Field

The Address bar or the Site Description field is a common field users would like to see on every page. It will contain various sections of the site like homepage, product page, company description page and so on. To have it displayed on every page of your website, you can create a global field in your content type and name it Address Bar or Site Description.

To do this, follow the steps given below:

  1. Similar to the previous example, create a global field named Site Description.
  2. Drag and drop the fields you want to add in the Address bar section. In Edit Properties you can define the properties of the fields. For our example we have added the following fields:
    • Modular Block: Add various sections of the site in this field.
    • Link: Each modular block will contain call to action links which will redirect users to various web pages of your site.
  3. The global field is ready to use in your content type(s).
  4. Open the Content Type Builder of the content type, where you want to add the Site Description field. Now, drag and drop the Global Field and select Site Description from the Select Global Field dropdown.
  5. Also, add a suitable Display Name and Edit Properties accordingly.

Example 3: Taxonomy group field as a global field

Taxonomy refers to classification of content into various groups, categories, or tags according to their common characteristics. Structuring or organizing content is a common and useful practice, which helps users to easily find the subject of their interest.

This categorization can be achieved by using the global field in Contentstack. Let's understand this through the use of a sports website example.

Here, we will present the categories of sports on each webpage which will help the users for easy navigation.

Follow the steps given below to implement this:

  1. Login to your Contentstack account, create a content typeand go to the Global Fields tab.
  2. Now, click on + New Global Field button and add a suitable name and description to your global field. Then, click on Create and Add fields.
  3. Drag and drop the fields you want to add in the Sports section. In the Edit Properties section, you can define the properties of the fields. For our example we have added following fields:
    • Modular Block: The modular blocks field is used to specify sports categories in the header of the page. Each block will contain a group field.
    • Group field: Select Multiple option in group field setting as we will be creating multiple groups under each modular block which will help us to collectively add similar types of sports.
    • Each group field contains the following fields:
    • Single Line Textbox: This field will contain the title/ name of the sports subcategory.
    • Link: Each group will contain multiple links to the individual landing pages of that sport.
  4. The global field setup is done. Now, add this global field to your content type(s).
  5. Go to your Edit Content Type page, drag and drop the global field and select Site Description from the Select Global Field dropdown.
  6. Add a suitable Display Name and Edit Properties accordingly.

Read more about Complex fields and how each field can be used within the Global field.

Example 4: Website Banner

Every dynamic website consists of a Banner section at the top of the page. This banner is common to several pages of the website. The content on each banner may differ, but the content model remains the same on each page.

This can be easily done using the Global Field. The unique property of the global field to be reusable across all content types, makes it the perfect choice for this use case.

You just have to define the website banner in the global fields section and then use it across your content types to be rendered on various pages of your website.

Let's create a banner for a website using a group field. Follow the steps given below:

  1. Log in to your Contentstack account, create a content typemodule and select the Global Fields tab.
  2. Now, click on + New Global Field button and add a suitable name and description to your global field. Click on Create and Add fields.
  3. Drag and Drop the fields you want to add in the Banner section. In Edit Properties you can define the properties of the fields.
  4. Once added, drag and drop the following fields from the Fields list into your global field. The Banner contains the following fields:
    • Banner Image: Use the File field to add a banner image of the website.
    • Bg color: To add the background color of the banner, we have used our pre-built Color Picker Custom Field Extension.
    • Banner Title: The Single Line Textbox field contains the title of the banner.
    • Banner Description: Banner description and related text can be added using the Multi Line Textbox field.

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page

^