Site Columns: The Power of the Highlighted Content Web Part 

December 21, 2020 James Cragle

web part

SharePoint Online has a lot of web parts. The list of web parts keeps growing every day. One of the most powerful and adaptable web parts is the highlighted content web part. This web part has a multitude of configurations and is extremely adaptable.  

In a previous post, we talked about site columns vs. list columns, and we will use some of that here in the examples. You may want to go review that article before we get to the custom configuration section of this web part.  

Default configuration 

Every web part has a default configuration, and the highlighted content web part is no exception. When added to a page, the web part will surface all documents in all sites in the hub. Since this probably doesn’t meet your needs, let’s start making changes to the switches and options to try to make it better. The highlighted content web part is usually easy to find when adding a web part; if not, type the name into the search box. 

web part

Content Selection  

After the web part is added to the page, we can start customizing the sections.  

Web Part Source 

We can choose where our highlighted content comes from. There are a lot of choices when it comes to the webpart source. The source can be very broad like all sites in the hub or you can choose content to display from a single library. This all depends on what you intend to show the audience.  

web part

Type (Content Type) 

This section can be a little confusing since most of us only deal with documents. If you want to display any type of content, choose “all” or, if you only want images or tasks, choose those to show. This makes finetuning your highlighted content easier to do. 

 web part

Type (Document Type) 

There are several predetermined types of content that can be returned to the web part. The out-of-the-box options are the most common types of documents you will experience in SharePoint.   

 web part

Custom content types and document types 

If there is a document type, like a CAD file that you want to display, you will need to add it to the list of document types. Same thing for a custom content type. If my IT organization or I have created a custom content type, I can still use it in my highlighted content. 

web part

Filter and Sort 

There is an extensive amount of filtering that you can do right from the user interface. We will talk about custom filters later in this post.

Filter 

The filter drop down has several pre-determined filters that you can apply to your content. When you choose a filter, you will need to supply a text value for the filter to act on. The recently changed and recently added will require you to pick a timeframe from a dropdown list. The content updates immediately when changing the selections so you can see in real time what the results will be. 

web part

Additional Filters 

You can create multiple filters for your content but be sure to experiment with them. Multiple filters can cause some unexpected results. This is because these filters will process from the top down, so make sure you start with the broadest categories first and then the finer filters at the bottom. Here we are searching for documents recently added this month with the content of the document containing “titania.” This brings back two results because in the Oberon document, Titania was mentioned as a sister moon.  

web part

Sort by 

Sort by what is most meaningful. There are alphabetical options and popularity options. Just remember to set your sorting so all the documents that you need to show up do. If you want to show all documents for a month, then the layout probably needs to show more than the default eight items.  

web part

Enable audience targeting 

Audience targeting is a powerful way to show content to certain groups of people. In the highlighted content web part, this is just a switch that gets turned on or off. Audience targeting of content is done in the source libraries and lists where the content originates from.  

 web part

Layout 

The layout has a few different options. These views are not currently customizable, so you must pick the view that gives you the best fit for your content area. The web part is dynamically sized based on the screen size. As the screen gets smaller, the web part will change to a smaller footprint and may even change from grid to list to fit a certain screen resolution. You can show up to 500 items in your web part.  

web part

Advanced Query Configurations 

Now comes the best part of the article! You can take your filtering and query needs to a higher level with the Custom Query option on the web part.  

When selected, the default Source, Type and Document type settings is converted into a CAML or KQL data entry box. The web part is designed to change from KQL or CAML depending on the source you choose.  

First, a little about each query language. 

KQL – Stands for Keyword Query Language which is a natural language query tool for SharePoint. Some of the commands for using KQL are below.

  • Author: “John Smith” – will return all documents created by John Smith
  • Filetype: docx– will return all documents with a .docx extension 
  • Filename: moon OR planet – will return any document with a file name containing moon or planet 
  • Filename: moon AND planet – will return only documents that have both moon and planet in the title

You can find out more about KQL on the Microsoft KQL Syntax pages. 

CAML – Stands for Collaborative Application Markup Language, which is like an XML language. This language offers more complex comparisons and filters and takes more patience to get the expected results you want. The example query below will get the documents with Titania in the title.

Note: this query doesn’t function if copied and pasted. It is just for show.  

<query>
<contains>
<where>
<fieldref Name=’Title’>
<value Type=’Text’>Titania
</contains>
</where>
</query> 

CAML is more complex than KQL for a few reasons. It is very syntax sensitive and you must know internal field names. For more resources on CAML, start with The Introduction to Microsoft CAML. Also, search the web for people who have already built the queries you are looking for.  

Advanced queries in action 

KQL 

When I select Custom Query and select “all sites in hub.” I will use KQL. This KQL query will find the documents that contain the word “Titania” in the title.  

web part

In the example below, I am using a custom Site Column as my filter. I am using the custom metadata value as a filter in the KQL statement. In this statement, I want all documents with the value “moon” from BodyType to be displayed. The query now retrieves all documents with that metadata.  

web part

CAML 

If you venture into the realm of CAML, I suggest you download one of the many CAML tools that can create a CAML query using a GUI. My personal favorite is SmartCAML. This allows you to troubleshoot your queries before you insert them into the CAML panel and will help you be more successful.   

web part

Conclusion 
If you need to retrieve and display content from a list, library, site or the entire SharePoint Online tenant you should start with the highlighted content web part. It is highly flexible and customizable. Unlike custom filtering and display solutions, the highlighted content web part is a Microsoft core web part and will be supported for a long, long time.  

 

About the Author
James Cragle is a Collaboration Consultant at New Signature in our Southeast United States region. He is an expert and lover of all things SharePoint, and helps our customers develop and manage dynamic and intelligent workplace environments. In his free time, James is an avid hiker and has recently started experimenting with gardening.

Previous Article
Is Platform Theory the New Systems Theory?
Is Platform Theory the New Systems Theory?

One of the biggest challenges we face talking to customers about our platform native story is helping them ...

Next Article
Microsoft 365 Defender – Unleash the NinjaCat in you
Microsoft 365 Defender – Unleash the NinjaCat in you

Microsoft 365 Defender brings together Microsoft’s threat protection stack with Microsoft Defender for Iden...