most-viewed

Generate a list of the most viewed articles for a section of the docs.

This shortcode is supported by the data from /data/pageviews.json, which is exported from Looker.

Examples

{{< most-viewed section="/products/billing/" keyword="billing" heading="Billing Articles" >}}

Renders to:

Parameters

  • section is the directory to be queried for articles using a filesystem tree search.
  • keyword is the taxonomy term that will be queried in Support and Tutorials for any matching articles.
  • heading is the text you’d like to insert after “Most Viewed” in the <h2> that appears at the top of the widget.
  • articles is how many articles to display in the list. The default is 10.

The combination of these queries is added up into a list of pages that is ordered by the number of page views, descending.

Under the hood

  • The data in /data/pageviews.json captures page view data for the last 90 days of activity and must be manually exported from Looker while logged in over VPN.
  • The HTML actually produced by calling this shortcode is generated by a partial, /layouts/partials/most-viewed.html. All this partial does is iterate over the list of pages handed to it by the calling page and produce the HTML; the logic for generating the list of pages is what is actually in the shortcode source at /layouts/shortcodes/most-viewed.html – as well as any layout files that integrate the partial, such as /layouts/ia/landing.html.