Google App Script: how to display google drive files with links to templated HTML

I'm new in both Google App Scripting and JavaScript. So, I'm trying to display the grabbed files from my Google Drive with links however when running displayData(); it's literally showing the link and the title of the file on the page without the actual link in it. Here's picture of the html output.

Here's what I have so far:

function doGet() {
  var output = HtmlService.createTemplateFromFile('Page').evaluate();
  return output;

function include(filename){
  return HtmlService.createHtmlOutputFromFile(filename)

function displayData() {
  var dir = 'Somefoldername';
  var foldername = DriveApp.getFoldersByName(dir).next();
  var foldercont = foldername.getFiles();
  var listicon = '<img src="">';
  var file, title, links, list = []; 
  while (contents.hasNext()) {
    file =;
    title = file.getName();
    links = file.getUrl();
    date = file.getDateCreated();
    list.push('<tr><td>' + listicon + '<a href ="' + links + '">' + title +'</td></tr>');
  return list;


<!DOCTYPE html>
    <base target="_top">
    <?!= include('Stylesheet'); ?>
    <div class="doclist">
    <?= displayData(); ?>


How would I display the Google Drive file hyperlinks in the html template?

Thank you.

Read more here:

Content Attribution

This content was originally published by Gray Farron at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: