skip to Main Content

I am trying to get my css.html file to be brought into my index.html and am using a html service to call the css file. Simple enough but I cannot seem to get the function to be seen as anything other than text. In the inspect tool it shows it as appearing in the body even though I am placing it in the header. Am I missing something with formatting or maybe it’s a page loading issue?

<head>
<base target="_top">

<?!= HtmlService.createHtmlOutputFromFile('css').getContent(); ?>

</head>

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    Finally got it working. I was using .createHtmlOutputFromFile() to create the HTML but it looks like I needed to create a template for the index and then create the CSS as HTML.

    function doGet() {
      return HtmlService.createTemplateFromFile('index').evaluate();
    }
    
        function include(filename) {
      return HtmlService.createHtmlOutputFromFile(filename).getContent();
    }
    

  2. Try this:

    You need to create a template and then use evaluate() method

    function include(filename) {
      return HtmlService.createHtmlOutputFromFile(filename).getContent();
    }
    
    <?!= include('css') ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search