Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include one html page to another in thymeleaf?

I have the following project structure in Spring Boot Application -

/templates/home/index.html

/templates/includes/header.html

I want to include the header file inside the index file. I have tried the link - https://stackoverflow.com/questions/23538693/include-html-page-in-thymeleaf#=

But the colon '::' is showing error.

I am new to thymeleaf. Can anybody explain? Thanks.

like image 807
forhadmethun Avatar asked Jun 10 '18 10:06

forhadmethun


1 Answers

Thanks all who tried to help me. I solved the problem as follows -

//header.html
<div th:fragment="header">
<!-- related code of header file >
</div>



//index.html
//to include header follow the code( the header file is inside includes directory) 
<div th:replace="/includes/header :: header"> </div>
like image 90
forhadmethun Avatar answered Sep 28 '22 10:09

forhadmethun