Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello, I am having trouble with embedding header including <head> tag in my couch site.

I want to embed header including:
Code: Select all
<head>
  <meta charset="utf-8">....

Using snippet stored in snippets/header/default.html and using <cms:smart_embed 'header' /> tag

However every time I run the site, I see "autoinserted" empty head tag and then my <head> tag inserted in <body>
Code: Select all
<html lang="cs"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">

Embedding different parts of the site works normally, but I am unable to figure out the head part.
Thanks for any suggestions,
D.
Please post your template code and snippet code. I'll help you get sorted the awesome cms:smart_embed tag :)
Hello, thanks for the reply!

Here is a simple template:
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>

<cms:template title="Kalendář" />

<!DOCTYPE html>
<html lang="cs">
<head>

<cms:smart_embed 'header' />   
   
</head>
<body>

<cms:smart_embed 'nav' />

<div class="parallax-window team" data-parallax="scroll" data-image-src="<cms:show k_site_link />img/header.jpg">
    <h1>Kalendář akcí</h1> 
</div>

<div class="container covering">
</div>

<div class="container-fluid covering2 shadow-top">
   <div class="container main">   
      <div class="row"> 
      <div class="col text-center">
        <h2>Kalendář akcí Basketbal Sokol Žižkov</h2> 
      </div>
      </div>
      <div class="row">
      <div class="col-12">
      <cms:pages masterpage='globals.php' >
        <cms:if "<cms:not_empty site_link_gcal />" >
            <div class="embed-responsive embed-responsive-16by9">
              <iframe class="embed-responsive-item" src="<cms:show site_link_gcal />" allowfullscreen></iframe>
            </div>
        </cms:if>
      </cms:pages>
      </div>
      </div>
</div>
</div>



<cms:smart_embed 'footer' />     

</body>
</html>

<?php COUCH::invoke(); ?>


And header snippet:
Code: Select all
  
<meta charset="utf-8">
    <title><cms:pages masterpage='globals.php' ><cms:show site_name /></cms:pages></title>
    <meta name="description" content="<cms:pages masterpage='globals.php' ><cms:show site_seo_description /></cms:pages>" />
    <meta name="keywords" content="<cms:pages masterpage='globals.php' ><cms:show site_seo_keywords /></cms:pages>" />
       
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <link rel="stylesheet" href="<cms:show k_site_link />css/owl.carousel.css">
  <link rel="stylesheet" href="<cms:show k_site_link />css/owl.theme.css"> 
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
 
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.css">   
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.css">     
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&amp;subset=latin-ext" rel="stylesheet">
  <link rel="stylesheet" href="<cms:show k_site_link />css/bootstrap.min.css">
  <link rel="stylesheet" href="<cms:show k_site_link />css/style.css">   


And when I run the site, the header inserts it to a different position than to head tag (see output).

Code: Select all
<!DOCTYPE html>
<!-- saved from url=(0040)http://localhost/zizkov_new/kalendar.php -->
<html lang="cs"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head><body><div class="parallax-mirror" style="visibility: visible; z-index: -100; position: fixed; top: 0px; left: 0px; overflow: hidden; height: 300px; width: 1586px; transform: translate3d(0px, 171px, 0px);"><img class="parallax-slider" src="./kalendar.php_files/header.jpg" style="position: absolute; height: 409px; width: 1586px; max-width: none; transform: translate3d(0px, -156.8px, 0px);"></div>
 
    <title></title>
    <meta name="description" content="">
    <meta name="keywords" content="">
       
  <link rel="stylesheet" href="./kalendar.php_files/bootstrap.min.css">
  <link rel="stylesheet" href="./kalendar.php_files/owl.carousel.css">
  <link rel="stylesheet" href="./kalendar.php_files/owl.theme.css"> 
  <link rel="stylesheet" href="./kalendar.php_files/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
 
  <link rel="stylesheet" href="./kalendar.php_files/chartist.min.css">   
  <link rel="stylesheet" href="./kalendar.php_files/ekko-lightbox.css">     
  <link href="./kalendar.php_files/css" rel="stylesheet">
  <link href="./kalendar.php_files/css(1)" rel="stylesheet">
  <link rel="stylesheet" href="./kalendar.php_files/bootstrap.min(1).css">
  <link rel="stylesheet" href="./kalendar.php_files/style.css">     
...
...
...
   


Thanks for any help.
D.
Hi, you should disable any caching and try to isolate the issue with your files and snippets. Clearly, HTML doesn't match. It is not the problem with cms:smart_embed..

Try to move things online and see at what moment the problem appears.
Adding to @trendoman's suggestions - as mentioned in the 'Debugging' section (https://docs.couchcms.com/miscellaneous ... #debugging) please also try adding debug='1' to the problem <cms:smart_embed /> tag. It will show which snippets it its searching for and which one it finally selects.

Hope this helps.
5 posts Page 1 of 1