Skip to main content

Embed Code from an External Source

You can set your help content to use the latest code samples from a repository, such as GitHub or BitBucket. Once set up, your HTML5 help will be able to update code samples automatically, without being republished.

Note

The code samples need to be in an "https" URL.

Tip

For embedding Swagger/Open API code, see Embed Swagger OpenAPI.

Use dynamic code snippets to have your HTML5 output to use "live" code snippets from a repository.

  1. Select Layout in the top menu.

    Paligo editor. The Layout option in the header menu is highlighted.

    Paligo displays a list of Layouts. The list is empty if there are no custom Layouts in your Paligo instance.

  2. Select the Layout you want to update or Create a Layout.

    Tip

    You can copy the URL of the Layout Editor and paste it into a new tab in your browser. This can be useful if you frequently switch between your Paligo content and the Layout settings.

  3. Select Classes and attributes in the sidebar.

    Classes_and_Attributes.png
  4. Select Enable for Output 'role' attribute as class names.

    Layout. Output role attribute as class names setting. It is set to Enable.
  5. Select Save.

  6. Select the topic or component in the Content Manager to open it in the Editor.

    Content Manager in Paligo. It shows the Documents section contains an Acme 100 Topics folder. Inside the folder there is a publication and many topics, including "Connect to Network (100).

    Alternatively, you can Create a Topic and edit that.

  7. Select the position where you want the code to appear.

  8. Press Alt + Enter ⏎ (Windows) or Command ⌘ + Enter ⏎ (Mac) to display the Element Context Menu.

    Element context menu shows a search field and a list of elements that are valid at the current position.
  9. Add a code block element, either programlisting or screen.

  10. Select the programlisting or screen element in the topic.

    Tip

    You can add a programlisting element with these attributes added by the shortcut Alt,. Then you just need to add the URL value.

  11. Add these attributes and values In the Element Attributes Panel:

    • role attribute with the value embedcode

    • xlink:href attribute with the URL to the code snippet in your repository.

  12. Optional: If you want or need fallback code for other output formats, add the code snippet in the programlisting or screen element as well.

  13. Select Save. Save icon.

When you publish, your code will be fetched from the repository and will be automatically updated if that code changes.

Note

If you also publish to other outputs such as PDF, the embedded code will still be fetched dynamically at publish time. But if you change the code samples in your repository, you will need to republish the PDF output to have Paligo fetch the latest changes.