LoginSignup
2

More than 5 years have passed since last update.

Sphinxドキュメントにトラッキングコードを追加する

Posted at

概要

sphinx_rtd_theme を使ったSphinx ドキュメントにトラッキングコードを追加する方法の備忘録.

方法

sphinx_rtd_theme の layout.htmlにある,extrabody ブロックを使う.

作成中ドキュメントの _template ディレクトリに次のような内容の layout.html を作成する.

layout.html
{% extends "!layout.html" %}

{% block extrabody %}
  <script>
    トラッキングコードを埋め込むスクリプト
  </script>
{% endblock %}

{% extends "!layout.html" %} で sphinx_rtd_theme の layout.html を拡張することを宣言し,extrabody の内容を定義している.

後はコンパイルすれば良い.

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2