Add scripts to articles

To add scripts like JavaScript or other code to your articles, you can use one of two options:

For simple scripts

For simple scripts, toggle the article editor to Code View (the </> icon) and paste your script directly into the article.

Once you save the article, toggle back to Code View and be sure your script saved. If it didn't, follow the next set of instructions.

For complex or reusable scripts

If the article editor strips our your code on-save, or if you have code you'd like to use in multiple articles, create a snippet to contain the code and then add that snippet to the articles where you want the script to appear.

  1. In the lefthand navigation, go to Snippets.
  2. Select + Create New Snippet. If you're unfamiliar with creating snippets, refer to Create a snippet for more detailed instructions.
  3. Enter a Snippet Name like Redocly script.
  4. Enter a Snippet Description like This snippet contains the code to run Redocly to display our API documentation so it won't get stripped out of the editor..
  5. Select the Snippet Content dropdown and select Code Editor:
  6. Paste your full code into the editor.
  7. Leave your snippet in the Code Editor; do NOT toggle back to WYSIWYG Editor.
  8. Select Create to create and save your snippet.

Now you can insert the snippet into any article where you want the script to run. Refer to Add snippets in content for more detailed instructions.