What are conref and conkeyref in DITA?

In DITA, “conref” and “conkeyref” are mechanisms that enable content reuse and linking, making it easier to manage and maintain structured documentation. They are particularly useful for large-scale projects and modular content creation.

Conref (Content Reference)

Conref stands for “Content Reference.” It allows you to reference and reuse content from one topic within another. You can include the entire content or specify specific elements from the source topic. Conref is commonly used when you want to reuse standard content, such as legal disclaimers or copyright notices, across multiple documents. It helps ensure consistency and reduces redundancy. Here’s an example:


<p>This is an example of conref. <conref href="legal_disclaimer.dita"/> This text comes from another topic.</p>

In this example, the content of the “legal_disclaimer.dita” topic is included within the current topic using conref.

Conkeyref (Content Key Reference)

Conkeyref, or “Content Key Reference,” takes content reuse a step further. It allows you to reference content based on a key or attribute value rather than a specific file. This means that you can create conditional content that adapts to the context in which it’s used. For instance, you can use conkeyref to display content differently based on the product, audience, or language. Here’s an example:


<p>Depending on the product, <conkeyref keyref="product-key">this content</conkeyref> will change.</p>

In this case, “product-key” is an attribute value that determines which content is displayed based on the product being documented.

Conref and conkeyref are powerful tools in DITA that facilitate content reuse and conditional content rendering, streamlining the management of complex documentation projects and ensuring consistency and accuracy across documents.