Likely a silly question, but is there anyway to host and run my template based website on github pages?

agolangf · · 448 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>So I simplified a website using templates, setup a github.io site. Just curious if I can host my golang site on github or if I need my own server to run main.go(main.exe)?</p> <hr/>**评论:**<br/><br/>justinisrael: <pre><p>I might be wrong, but as far as I know, github pages only serve static content. I currently use it to host my own site. It uses Hugo to generate static content. </p></pre>GoArray: <pre><p>Looks like you&#39;re spot on, thanks!</p></pre>tv64738: <pre><p>I generate static files with Go templates and use Github Pages to serve them. Why would Github care (/be able to know) how the file content was generated?</p></pre>GoArray: <pre><p>I&#39;ll have to look into this. I&#39;m only up to having {{template header}} in index.html and {{define header}} in header.html. I thought go was required to link them?</p></pre>tv64738: <pre><p>So use Go to create the HTML you need. Github Pages only cares about the resulting file, not how you created it.</p></pre>GoArray: <pre><p>I must be missing something, or mis-explaining? Or just not understanding.. lol </p> <p>So here&#39;s my index.html: </p> <hr/> <p>&lt;!DOCTYPE HTML&gt;<br/> &lt;html&gt; </p> <p>{{template &#34;header&#34;}} </p> <p>&lt;body&gt;<br/> &lt;div id=&#34;main&#34;&gt;<br/> &lt;div id=&#34;header&#34;&gt;<br/> {{template &#34;logo&#34;}} {{template &#34;navbar&#34;}}<br/> &lt;/div&gt;<br/> &lt;div id=&#34;content_header&#34;&gt;&lt;/div&gt;<br/> &lt;div id=&#34;site_content&#34;&gt;<br/> &lt;div id=&#34;banner&#34;&gt;&lt;/div&gt;<br/> &lt;div id=&#34;sidebar_container&#34;&gt;<br/> {{template &#34;sbfavs&#34;}} {{template &#34;sblinks&#34;}} {{template &#34;sbsmed&#34;}}<br/> &lt;/div&gt;<br/> &lt;div id=&#34;content&#34;&gt;<br/> {{template &#34;dindex&#34;}}<br/> &lt;/div&gt;<br/> &lt;/div&gt;<br/> {{template &#34;footer&#34;}}<br/> &lt;/div&gt;<br/> &lt;/body&gt; </p> <p>&lt;/html&gt; </p> <hr/> <p>So, it&#39;s a *.html, but it won&#39;t display properly because main.go is needed to execute the template placeholders. I kind of thought you were saying I could output my template format into standard html, but no?</p></pre>tv64738: <pre><p>Naming a file *.pptx doesn&#39;t make it a PowerPoint presentation.</p> <p>Run a Go program that executes the template.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

448 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传