1

I have articles on my site that can contain one or more photo galleries that are related to the article's content. The schema.org/ImageGallery is defined as a "Web page type: Image gallery page" and as such inherits from the schema.org/WebPage type. The gallery opens up in a lightbox without changing pages though.

Is there a more appropriate type for a gallery that is just a feature on a page, related to the larger containing article?

I have seen the bib Collection type but it's low usage (Usage: Between 10 and 100 domains) and fact that it's not in core makes me concerned.


I've seen this related question but their question is more about the images.

  • I wonder if just adding the ImageType for each image can be correct. This way you can have a WebPage (your article) with a list of images (the gallery). – ribluc Sep 2 '17 at 5:44
1

I agree that ImageGallery is not a suitable type for your case.

There are two alternatives to Collection, but they have drawbacks, so I think Collection is the best solution here.

hasPart

The most simple solution would be to use multiple values for the hasPart property:

<article itemscope itemtype="http://schema.org/Article">
  <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
  <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
  <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
</article>

Problem: It doesn’t allow you to group the images into sets. So if it’s important for you to convey which gallery the images belong to (in case an article has multiple galleries), this doesn’t work.

ItemList

The ItemList type can be used to group the images (where each gallery is represented by a list).

Problem: You can’t connect the ItemLists to the Article, because the hasPart property expects a CreativeWork as value, but ItemList isn’t one.

(One case where it does work is if the galleries are the primary items described in the article. In that case, you could use the mainEntity property to connect the ItemLists to the Article.)

Collection

Collection is a CreativeWork, so hasPart can be used:

<article itemscope itemtype="http://schema.org/Article">
  <div itemprop="hasPart" itemscope itemtype="http://schema.org/Collection">
    <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
    <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
    <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
  </div>
  <div itemprop="hasPart" itemscope itemtype="http://schema.org/Collection">
    <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
    <div itemprop="hasPart" itemscope itemtype="http://schema.org/ImageObject"></div>
  </div>
</article>

(If needed, you could of course also combine this with ItemList.)

There is no need to be concerned:

  • For deciding which type to use, ignore the usage statistics.
  • It’s no problem that a type is part of an extension. It’s just an organizational decision. Everything in an extension is still part of the main namespace (i.e., you can/should use http://schema.org/Collection instead of http://bib.schema.org/Collection).
  • Thanks for this detailed answer. I will look at articles with more than one gallery to decide if the simple hasPart solution works well enough for my needs, but may end up using Collection at the end of the day because there may be situations in the future where galleries show up on types other than articles. – tenor528 Sep 5 '17 at 14:39
  • One more clarifying comment: These galleries are in the middle of the Article.articleBody which is of a type text, so it'd probably be invalid to do this with microdata. I'd have to use JSON+LD to have it properly/validly related to the article. – tenor528 Sep 7 '17 at 17:45
  • @tenor528: Should be fine to use it in Microdata. The text (btw., you may want to use articleBody) property takes the textContent as value, it ignores any markup (including Microdata) in that content. – unor Sep 8 '17 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.