How To: Link to an HPT entity

Last updated on
25 April 2023

As described in Inside Info: Canonical Link, Alias, Redirect, and Pathauto, if you link to an hpt entity, the end user will be served the file from an appropriate alias. Let's look at a just a few simple ways to link to an hpt entity.

Here we will add a link to the main navigation that serves a pricing document to the end user. The admin navigates to Structure > Menus > Main Navigation and then clicks "Add menu link". We can fill out the form as follows:

We use the canonical path (/hpt/1). Alternatively, we can use entity:hpt/1, although I don't personally consider that an improvement.

After we save, we can view the main navigation. When we hover over the "Pricing" link, we see that the standardized alias is used.

As discussed in the previous page of the guide, that's because the link_generator service replaces the canonical link with the entity's alias. This is good news because it follows the cms.gov standards and it will continue to do so even after the file is updated, which is supposed to happen at least yearly.

We can easily link to an hpt entity within a WYSIWYG as shown in the image below.

Once again, we use the canonical link. This time, however, the link_generator service does not get used, which means that the link will direct the user to the un-aliased path. If you have redirect installed (and you probably do!), the user will automatically be redirected to the aliased path.

Alternatively, you can install the contributed linkit module and configure it to work for Hospital Price Transparency entities. Then the link_generator service will be used and the link will be rendered using the hpt alias.

Once again, this link will continue to work correctly without an intervention even if hpt's file is updated, which is supposed to happen at least yearly.

Help improve this page

Page status: No known problems

You can: