· 3 min read

How to Embed Google Docs in GitLab Markdown File ?

This tutorial teaches you how to use Google Docs content as Markdown in GitLab instead of Embedding Google Docs in GitLab as iframe.

GitLab Community editions and GitLab Enterprise editions use GitHub-flavoured markdown in the text areas.

If your goal is to display Google Docs content in GitLab within text areas like Readme.md or Wikis, embedding Google Docs in GitLab is not the appropriate solution, and it is not possible too.

Because GitLab uses GitHub-flavored Markdown (gfm), and gfm does not support the embedding of <iframes> in Markdown.

As per GitLab docs:

GitHub Flavoured Markdown enables the tagfilter extension, where the following HTML tags will be filtered when rendering HTML output:

  • <title>

  • <textarea>

  • <style>

  • <xmp>

  • <iframe>

  • <noembed>

  • <noframes>

  • <script>

  • <plaintext>

iframe will be filtered by the tagfilter extension due to the security concerns such as Content spoofing and Cross site scripting.

Hence, the right way to use the Google Docs content in GitLab is to convert the Google Docs into Markdown format and update into GitLab. There are two options to add the content of Google Docs to GitLab as Markdown.

  • Converting Google Docs to Markdown and Paste in GitLab file

  • Commit the Google Docs Content as Markdown to GitLab directly

Both of these options are possible using the Docs to Markdown Pro from Google Docs add-on.

Install this add-on and read further to learn how to use Google Docs content as Markdown in GitLab text areas.

Converting Google Docs to Markdown and Paste in GitLab file

This section explains how to convert Google Docs content to Markdown text and manually paste the text into a GitLab text area, for example, readme.md.

  1. From the Extensions menu, select Docs to Markdown Pro > Convert To Markdown (Copy or Save as a file) option.

  2. Click the “To Markdown” button. The Google Docs content will be converted to Markdown format, and the output text will be displayed and copied to the clipboard.

  3. Navigate to the GitLab repository and open the file to which you need to add the Google Docs content.

  4. Paste the copied content and commit it.

  5. That’s it. Now, your Google Docs content has been updated in GitLab as Markdown.

Note: This process involves manual effort.

In the next section, let us see how you can commit Google Docs content as Markdown to GitLab.

Committing the Google Docs Content as Markdown to GitLab 

The Docs to Markdown Pro add-on allows you to commit Google Docs content as Markdown without manual effort. Here is how to do it:

  1. From the Extensions menu, select Docs to Markdown Pro > Export as Markdown to GitHub or GitLab option

  2. On the top left corner, click the Settings window. The settings window will open, allowing you to configure your GitLab repository using the username, personal access tokens, and other data such as Markdown commit location and images commit location. Once configured, close the configure window (this is a one-time activity).

  3. In the Export as Markdown window, select the Git branch to which you need to commit the Google Docs as Markdown

  4. Update the Markdown file name as required

  5. Optionally, if you need to include Front Matter for static sites, use the Edit Front Matter option and update the necessary details.

  6. Finally, click the Push to Git option

  7. The Google Docs content will be converted to Markdown format and pushed to your GitLab repository

  8. If you need to update the contents, make the necessary changes in Google Docs, and click the Push to Git option. The updated content will be committed to the GitLab file

Advantages of Using the Add-on

  • Eliminates manual work, saving time.

  • Images are automatically uploaded to Git, and their paths are updated in the generated Markdown.

  • Ensures error-free conversion.

  • Facilitates seamless updates when there is a change in the content.

Back to Blog