title: Pass variable between fragments Thymeleaf
body: <p>My structure</p>
  <pre><code>WEB-INF
  └── thymeleaf
      ├── fragments
      │   └── head.html
      ├── index
      │   └── index.html
      └── layout.html
  </code></pre>
  <p><code>layout.html</code></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head th:insert=&quot;~{fragments/head :: head}&quot; th:remove=&quot;tag&quot;&gt;&lt;/head&gt;
  &lt;body&gt;
      &lt;!--${view} == &quot;index/index&quot;--&gt;
      &lt;div th:insert=&quot;~{${view} :: content}&quot; th:remove=&quot;tag&quot;&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><code>index.html</code></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head&gt;
      &lt;title id=&quot;pageTitle&quot;&gt;My Title with ID&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div th:fragment=&quot;title&quot;&gt;My Title With fragment&lt;/div&gt;
  &lt;div th:fragment=&quot;content&quot;&gt;
      My page
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><code>head.html</code></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head th:fragment=&quot;head&quot; th:remove=&quot;tag&quot;&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;??????&lt;/title&gt;
      &lt;link href=&quot;/css/bootstrap.css&quot; rel=&quot;stylesheet&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>I'm new to <code>Spring</code> and <code>Thymeleaf</code>. I'm trying to build a simple CRUD, but I'm stuck in the following situation:</p>
  <p>What I want is: in <code>index.html</code> set a <code>title</code> variable and in <code>head.html</code> <code>fragment</code> retrieve this <code>title</code> variable and print it.</p>
  <p>What can I do?</p>