Remove all references to baseurl in templates

This commit is contained in:
Ryan Watters 2017-03-05 03:47:06 -06:00
parent e0c3e9062b
commit 72685a7481
15 changed files with 28 additions and 38 deletions

View File

@ -15,18 +15,18 @@ toc: true
wip: true
---
Go 1.6 includes a powerful new keyword, `block`. This construct allows you to define the outer shell of your pages one or more master template(s), filling in or overriding portions as necessary.
Go 1.6 includes a powerful new keyword, `block`. This construct allows you to define the outer shell of your pages' one or more master template(s) and then fill in or override portions as necessary.
## Base Template Lookup Order
This is the order Hugo searches for a base template:
This is the order Hugo searches for your base template:
1. `/layouts/<CURRENTPATH>/<TEMPLATENAME>-baseof.html`
2. `/layouts/<CURRENTPATH>/baseof.html`
3. `/layouts/_default/<TEMPLATENAME>-baseof.html`
4. `/layouts/_default/baseof.html`
As an example, with a site using the theme `exampletheme`, when rendering the section list for the section `post`. Hugo picks the `section/post.html` as the template and this template has a `define` section that indicates it needs a base template. This is then the lookup order:
As an example, let's assume your site is using the theme when rendering the section list for the section `post`. Hugo picks the `section/post.html` as the template and this template has a `define` section that indicates it needs a base template. This is then the lookup order:
1. `/layouts/section/post-baseof.html`
2. `/themes/<THEME>/layouts/section/post-baseof.html`
@ -59,8 +59,9 @@ The following defines a simple base template at `_default/baseof.html`). As a de
{{ block "main" . }}
<!-- The part of the page that begins to differ between templates -->
{{ end }}
<!-- More shared code, perhaps a footer -->
{{ block "footer" . }}
<!-- More shared code, perhaps a footer but that can be overridden if need be in -->
{{ end }}
</body>
</html>
```

View File

@ -5,7 +5,7 @@
<h1>Page Not Found</h1>
</header>
<div class="body-copy">
<a href="{{.Site.BaseURL}}"><i class="icon-home"></i> Go Home</a>
<a href="/"><i class="icon-home"></i> Go Home</a>
</div>
</article>
</main>

View File

@ -5,7 +5,6 @@
<header class="content-header">
{{partial "breadcrumb.html" . }}
<h1 class="page-title {{if eq .Kind "page"}}{{.Section}}{{end}}" id="{{ .Title | urlize }}">
<!-- {{- partial "list-icon.html" . -}} -->
{{- .Title | markdownify -}}</h1>
{{partial "content-header-links.html" . }}
{{partial "tags.html" . }}

View File

@ -2,7 +2,7 @@
<main class="main">
<div class="content">
<header class="content-header">
<h1 class="page-title"><a href="{{.Site.BaseURL}}{{.Data.Plural}}"><i class="icon-{{.Data.Plural}}"></i>{{.Data.Plural}}:</a>&nbsp;{{ replace .Title "-" " "}}</h1>
<h1 class="page-title"><a href="/{{.Data.Plural}}"><i class="icon-{{.Data.Plural}}"></i>{{.Data.Plural}}:</a>&nbsp;{{ replace .Title "-" " "}}</h1>
</header>
<div class="body-copy taxonomies">
{{partial "contents-list.html" . }}

View File

@ -7,7 +7,6 @@
<div class="body-copy taxonomies">
{{ $data := .Data }}
{{ $dataPlural := add (.Title | urlize) "/"}}
{{ $base := $.Site.BaseURL }}
<table class="terms-table">
<thead>
<tr>

View File

@ -2,8 +2,7 @@
<nav class="breadcrumb">
<ul class="breadcrumbs">
<li>
<a class="crumb" href="{{.Site.BaseURL}}{{.Section | urlize}}">
<!-- <img src="{{.Site.BaseURL}}images/hugo-icons/{{.Section | urlize}}.svg" alt=""> -->
<a class="crumb" href="/{{.Section | urlize}}">
<span>{{replace (replace .Section "-" " " | title) "And" "and"}}</span>
</a>
</li>

View File

@ -5,7 +5,6 @@
<a {{with .Params.sitelink }}href="{{.}} "target="_blank"{{else}}href="{{.Permalink}}"{{end}}>
<section class="contents-list {{$kind}}">
<header>
<!-- <h3 class="list-icon {{.Section}}">{{- partial "list-icon.html" . -}}{{.Title | markdownify}}{{with .Params.sitelink }}&nbsp;<i class="fa fa-external-link" aria-hidden="true"></i>{{end}}</h3> -->
<h3 class="list-icon {{.Section}}">{{.Title | markdownify}}{{with .Params.sitelink }}&nbsp;<i class="fa fa-external-link" aria-hidden="true"></i>{{end}}</h3>
</header>
<p>{{.Description | markdownify }}</p>

View File

@ -1,11 +1,11 @@
<!-- Favicons - go to http://realfavicongenerator.net/ for easy generation after you've designed your logo.-->
<link rel="apple-touch-icon" sizes="180x180" href="{{.Site.BaseURL}}images/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" href="{{.Site.BaseURL}}images/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="{{.Site.BaseURL}}images/favicons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="{{.Site.BaseURL}}images/favicons/manifest.json">
<link rel="mask-icon" href="{{.Site.BaseURL}}images/favicons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="{{.Site.BaseURL}}images/favicons/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/images/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/images/favicons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/images/favicons/manifest.json">
<link rel="mask-icon" href="/images/favicons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/images/favicons/favicon.ico">
<meta name="msapplication-TileColor" content="#2d89ef">
<meta name="msapplication-TileImage" content="{{.Site.BaseURL}}images/favicons/mstile-144x144.png">
<meta name="msapplication-config" content="{{.Site.BaseURL}}images/favicons/browserconfig.xml">
<meta name="msapplication-TileImage" content="/images/favicons/mstile-144x144.png">
<meta name="msapplication-config" content="/images/favicons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

View File

@ -9,7 +9,7 @@
{{- end -}}
<meta property="og:locale" content="en_US">
<meta property="og:title" content="{{ .Title }}">
<meta property="og:image" content="{{.Site.BaseURL}}images/{{ .Site.Params.defaultsocialimage }}">
<meta property="og:image" content="/images/{{ .Site.Params.defaultsocialimage }}">
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="800" />
<meta property="og:image:height" content="533" />

View File

@ -4,5 +4,5 @@
<div class="hero-tagline">The world's fastest static website engine.
<br>Written in Golang.</div>
<div class="get-started">
<a role="button" class="button xl" href="{{.Site.BaseURL}}getting-started/quick-start">Get started</a>
<a role="button" class="button xl" href="/getting-started/quick-start">Get started</a>
</div>

View File

@ -1,4 +0,0 @@
{{$sect := .Section}}
<div class="list-icon-wrapper">
<img class="hugo-icon" src="{{$.Site.BaseURL}}images/hugo-icons/{{$sect}}.svg" alt="">
</div>

View File

@ -1,9 +1,8 @@
{{$version := .Site.Params.release }}
{{$base := .Site.BaseURL}}
<header id="site-header" class="site-header">
<div class="hugo-meta" title="Hugo version {{$version}}">
<a href="/" id="home-link">
<img src="{{$base}}images/hugo-icons/hugo-logo-wide.svg" alt=""><span class="hugo-v">v{{$version}}</span>
<img src="{{ "images/hugo-icons/hugo-logo-wide.svg" | relURL}}" alt=""><span class="hugo-v">v{{$version}}</span>
</a>
<!-- From https://buttons.github.io/. -->
<!-- <a class="github-button" href="https://github.com/spf13/hugo" data-icon="octicon-star" data-style="mega" data-count-href="/spf13/hugo/stargazers" data-count-api="/repos/spf13/hugo#stargazers_count" data-count-aria-label="# stargazers on GitHub" aria-label="Star spf13/hugo on GitHub">Star</a> -->

View File

@ -7,13 +7,12 @@
</a>
<nav class="site-navigation" id="site-navigation">
<ul class="top-menu">
{{$base := $.Site.BaseURL}}
{{$.Scratch.Set "currentsection" $.Section}}
{{$.Scratch.Set "currentpage" .Permalink }}
{{$.Scratch.Set "url" .URL }}
{{range $item, $params := sort ($.Site.Data.sitenavigation) "order"}}
{{$section := $params.url}}
<li class="top-menu-item"><a class="list-icon top-menu-item-link {{$params.haschildren}}{{if eq ($.Scratch.Get "currentsection") $section }} active-section{{end}}" href="{{if $params.haschildren}}#{{else}}{{$base}}{{$params.url}}{{end}}">{{$params.title}}</a>
<li class="top-menu-item"><a class="list-icon top-menu-item-link {{$params.haschildren}}{{if eq ($.Scratch.Get "currentsection") $section }} active-section{{end}}" href="{{if $params.haschildren}}#{{else}}/{{$params.url}}{{end}}">{{$params.title}}</a>
{{if $params.haschildren}}
<ul class="submenu">
{{- if eq $params.sortsubpagesby "title"}}
@ -33,8 +32,7 @@
<div class="nav-buttons">
<a role="button" href="https://github.com/spf13/hugo/releases"><i class="icon-download"></i>Download Hugo</a>
<a role="button" href="{{.Site.Params.discuss}}" target="_blank"><i class="icon-forum"></i> Discuss Hugo</a><br>
<a role="button" href="https://github.com/spf13/hugo/issues/new" target="_blank"><i class="icon-github"></i> File an Issue</a><br>
<!-- <a role="button" href="{{.Site.BaseURL}}mailing-list/"><i class="icon-mail"></i>Join the Mailing List</a> -->
<a role="button" href="https://github.com/spf13/hugo/issues/new" target="_blank"><i class="icon-github"></i> File an Issue</a>
</div>
</nav>
{{ end }}

View File

@ -1,7 +1,7 @@
<script src="{{.Site.BaseURL}}js/vendor/jquery-2.2.4.min.js"></script>
<script src="{{.Site.BaseURL}}js/script.min.js"></script>
<script src="/js/vendor/jquery-2.2.4.min.js"></script>
<script src="/js/script.min.js"></script>
{{ if ne .Params.toc "false" }}
<script async defer src="{{.Site.BaseURL}}js/table-of-contents.js"></script>
<script async defer src="/js/table-of-contents.js"></script>
{{ end }}
{{$gaid := .Site.Params.googleanalyticstrackingcode }}

View File

@ -6,13 +6,13 @@
{{.Content}}
</header>
<ul id="showcase">
{{$base := .Site.BaseURL}}
{{- range .Data.Pages.ByPublishDate.Reverse -}}
{{$title := .Title | markdownify}}
{{$img := .Params.image}}
<li class="showcase-site">
<div class="image-wrapper">
<a href="{{.Params.sitelink}}" target="_blank">
<img src="{{$base}}images/showcase/{{.Params.image}}" alt="Screenshot thumbnail for the website {{.Title}}, {{.Description}}">
<img src="/images/showcase/{{$img}}" alt="Screenshot thumbnail for the website {{.Title}}, {{.Description}}">
</a>
</div>
<div class="showcase-meta">
@ -30,7 +30,7 @@
<ul class="tags showcase-tags">
<li class="tags-icon-li"><i class="icon-tags"></i></li>
{{- range . -}}
<li><a href="{{$base}}tags/{{. | urlize}}">{{.}}</a></li>
<li><a href="/tags/{{. | urlize}}">{{.}}</a></li>
{{- end -}}
</ul>
{{- end -}}