Permalink
Browse files

Refactor most absolute URLs to relative URLs

See #683
  • Loading branch information...
gcushen committed Sep 15, 2018
1 parent 6c40356 commit 6ef19085d4bebbc594d303fc286bb45ff6830491
View
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
cd exampleSite
hugo -t "hugo-academic-v3" --themesDir ../.. -p 1315 --i18n-warnings --ignoreCache server
hugo -t "academic" --themesDir ../../ -p 1315 --i18n-warnings server
View
@@ -10,7 +10,7 @@ <h1>{{ i18n "page_not_found" }}</h1>
<h2>{{ i18n "posts" }}</h2>
{{ range first 5 (where .Site.RegularPages "Section" "post") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
@@ -20,7 +20,7 @@ <h2>{{ i18n "posts" }}</h2>
<h2>{{ i18n "publications" }}</h2>
{{ range first 5 (where .Site.RegularPages "Section" "publication") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
@@ -30,7 +30,7 @@ <h2>{{ i18n "publications" }}</h2>
<h2>{{ i18n "talks" }}</h2>
{{ range first 5 (sort (where .Site.RegularPages "Type" "talk") ".Params.time_start" "desc") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
@@ -40,7 +40,7 @@ <h2>{{ i18n "talks" }}</h2>
<h2>{{ i18n "projects" }}</h2>
{{ range first 5 (where .Site.RegularPages "Section" "project") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
@@ -19,7 +19,7 @@
{{ $paginator := .Paginate .Data.Pages }}
{{ range $paginator.Pages }}
<div>
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
<div class="article-style">
{{ if .Params.summary }}
{{ .Params.summary | plainify | emojify }}
@@ -42,7 +42,7 @@
{{ $comments_enabled := and $.Site.DisqusShortname (not (or $.Site.Params.disable_comments $.Params.disable_comments)) }}
{{ if and $comments_enabled ($.Site.Params.comment_count | default true) }}
<span class="middot-divider"></span>
<a href="{{ $.Permalink }}#disqus_thread"><!-- Count will be inserted here --></a>
<a href="{{ $.RelPermalink }}#disqus_thread"><!-- Count will be inserted here --></a>
{{ end}}
{{ if isset $.Params "categories" }}
@@ -52,7 +52,7 @@
<span class="article-categories">
<i class="fas fa-folder"></i>
{{ range $k, $v := $.Params.categories }}
<a href="{{ ($.Site.GetPage (printf "categories/%s" .)).Permalink }}">{{ . }}</a>
<a href="{{ ($.Site.GetPage (printf "categories/%s" .)).RelPermalink }}">{{ . }}</a>
{{- if lt $k (sub $categoriesLen 1) -}}, {{ end }}
{{ end }}
</span>
@@ -20,7 +20,7 @@
"message": {{ i18n "cookie_message" | default "This website uses cookies to ensure you get the best experience on our website." }},
"dismiss": {{ i18n "cookie_dismiss" | default "Got it!" }},
"link": {{ i18n "cookie_learn" | default "Learn more" }},
"href": {{ with .Site.GetPage "privacy.md" }}{{ printf "%s" .Permalink }}{{ else }}"https://cookies.insites.com"{{ end }}
"href": {{ with .Site.GetPage "privacy.md" }}{{ printf "%s" .RelPermalink }}{{ else }}"https://cookies.insites.com"{{ end }}
}
})});
</script>
@@ -1,7 +1,7 @@
<footer class="site-footer">
{{ with .Site.GetPage "privacy.md" }}
<p class="powered-by">
{{ printf "<a href=\"%s\">%s</a>" .Permalink .Title | safeHTML }}
{{ printf "<a href=\"%s\">%s</a>" .RelPermalink .Title | safeHTML }}
</p>
{{ end }}
@@ -5,7 +5,7 @@
{{ $preview := $post.Params.header.preview | default true }}
{{ if and $post.Params.header.image $preview }}
<a href="{{ $post.Permalink }}">
<a href="{{ $post.RelPermalink }}">
{{ $img_src := urls.Parse $post.Params.header.image }}
{{ if $img_src.Scheme }}
<img src="{{ $post.Params.header.image }}" class="article-banner" itemprop="image">
@@ -15,7 +15,7 @@
</a>
{{end}}
<h3 class="article-title" itemprop="headline">
<a href="{{ $post.Permalink }}" itemprop="url">{{ $post.Title }}</a>
<a href="{{ $post.RelPermalink }}" itemprop="url">{{ $post.Title }}</a>
</h3>
<div class="article-style" itemprop="articleBody">
{{ if $post.Params.summary }}
@@ -27,7 +27,7 @@ <h3 class="article-title" itemprop="headline">
{{ end }}
</div>
<p class="read-more" itemprop="mainEntityOfPage">
<a href="{{ $post.Permalink }}" class="btn btn-outline-primary my-1">
<a href="{{ $post.RelPermalink }}" class="btn btn-outline-primary my-1">
{{ i18n "continue_reading" }}
</a>
</p>
@@ -2,5 +2,5 @@
<div class="pub-list-item" itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
<i class="far fa-newspaper pub-icon" aria-hidden="true"></i>
<a href="{{ $post.Permalink }}" itemprop="url"><span itemprop="headline">{{ $post.Title }}</span></a>
<a href="{{ $post.RelPermalink }}" itemprop="url"><span itemprop="headline">{{ $post.Title }}</span></a>
</div>
@@ -6,7 +6,7 @@
{{- end -}}
</span>
({{- .Date.Format "2006" -}}).
<a href="{{ .Permalink }}" itemprop="name">{{ .Title }}</a>.
<a href="{{ .RelPermalink }}" itemprop="name">{{ .Title }}</a>.
{{ if .Params.publication_short }}
{{- .Params.publication_short | markdownify -}}.
{{ else if .Params.publication }}
@@ -7,7 +7,7 @@
{{ end }}
{{ if .Scratch.Get "image" }}
<div>
<a href="{{ .Permalink }}">
<a href="{{ .RelPermalink }}">
{{ $img_src := urls.Parse (.Scratch.Get "image") }}
{{ if $img_src.Scheme }}
<img src="{{ .Scratch.Get "image" }}" class="article-banner" itemprop="image">
@@ -19,7 +19,7 @@
{{ end }}
<h3 class="article-title" itemprop="name">
<a href="{{ .Permalink }}" itemprop="url">{{ .Title }}</a>
<a href="{{ .RelPermalink }}" itemprop="url">{{ .Title }}</a>
</h3>
<div class="pub-abstract" itemprop="text">
@@ -5,7 +5,7 @@
{{- delimit . ", " | markdownify -}}
{{- end -}}
</span>.
<a href="{{ .Permalink }}" itemprop="name">{{ .Title }}</a>.
<a href="{{ .RelPermalink }}" itemprop="name">{{ .Title }}</a>.
{{ if .Params.publication_short }}
{{- .Params.publication_short | markdownify -}},
{{ else if .Params.publication }}
@@ -1,6 +1,6 @@
<div class="pub-list-item" style="margin-bottom: 1rem" itemscope itemtype="http://schema.org/CreativeWork">
<i class="far fa-file-alt pub-icon" aria-hidden="true"></i>
<a href="{{ .Permalink }}" itemprop="name">{{ .Title }}</a>
<a href="{{ .RelPermalink }}" itemprop="name">{{ .Title }}</a>
<div itemprop="author">
{{ with .Params.authors }}
{{- delimit . ", " | markdownify -}}
@@ -2,12 +2,12 @@
{{ $ := .content }}
{{ with $.Params.url_preprint }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_preprint" }}
</a>
{{ end }}
{{ with $.Params.url_pdf }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_pdf" }}
</a>
{{ end }}
@@ -20,19 +20,19 @@
</button>
{{ end }}
{{ with $.Params.url_code }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_code" }}
</a>
{{ end }}
{{ with $.Params.url_dataset }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_dataset" }}
</a>
{{ end }}
{{ if $.Params.projects }}
{{ range $.Params.projects }}
{{ with ($.Site.GetPage (printf "project/%s" .)) }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .Permalink }}">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .RelPermalink }}">
{{ i18n "btn_project" }}
</a>
{{ else }}
@@ -41,33 +41,33 @@
{{ end }}
{{ else }}
{{ with $.Params.url_project }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absLangURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relLangURL }}" target="_blank" rel="noopener">
{{ i18n "btn_project" }}
</a>
{{ end }}
{{ end }}
{{ with $.Params.url_poster }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_poster" }}
</a>
{{ end }}
{{ with $.Params.url_slides }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_slides" }}
</a>
{{ end }}
{{ with $.Params.url_video }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_video" }}
</a>
{{ end }}
{{ with $.Params.url_source }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}" target="_blank" rel="noopener">
{{ i18n "btn_source" }}
</a>
{{ end }}
{{ range $.Params.url_custom }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .url | absURL }}" target="_blank" rel="noopener">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .url | relURL }}" target="_blank" rel="noopener">
{{ .name }}
</a>
{{ end }}
@@ -3,7 +3,7 @@
{{ if gt $tagsLen 0 }}
<div class="article-tags">
{{ range $k, $v := $.Params.tags }}
<a class="badge badge-light" href="{{ ($.Site.GetPage (printf "tags/%s" .)).Permalink }}">{{ . }}</a>
<a class="badge badge-light" href="{{ ($.Site.GetPage (printf "tags/%s" .)).RelPermalink }}">{{ . }}</a>
{{ end }}
</div>
{{ end }}
@@ -7,7 +7,7 @@
{{ end }}
{{ if .Scratch.Get "image" }}
<div>
<a href="{{ .Permalink }}">
<a href="{{ .RelPermalink }}">
{{ $img_src := urls.Parse (.Scratch.Get "image") }}
{{ if $img_src.Scheme }}
<img src="{{ .Scratch.Get "image" }}" class="article-banner" itemprop="image">
@@ -19,7 +19,7 @@
{{ end }}
<h3 class="article-title" itemprop="name">
<a href="{{ .Permalink }}" itemprop="url">{{ .Title }}</a>
<a href="{{ .RelPermalink }}" itemprop="url">{{ .Title }}</a>
</h3>
<div class="talk-metadata" itemprop="startDate">
@@ -1,6 +1,6 @@
<div class="pub-list-item" style="margin-bottom: 1rem" itemscope itemtype="http://schema.org/Event">
<i class="fas fa-calendar-alt pub-icon" aria-hidden="true"></i>
<span itemprop="name"><a href="{{ .Permalink }}">{{ .Title }}</a></span>
<span itemprop="name"><a href="{{ .RelPermalink }}">{{ .Title }}</a></span>
<div itemprop="startDate">
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
@@ -2,36 +2,36 @@
{{ $ := .content }}
{{ with $.Params.url_pdf }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}">
{{ i18n "btn_pdf" }}
</a>
{{ end }}
{{ with $.Params.url_slides }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}">
{{ i18n "btn_slides" }}
</a>
{{ end }}
{{ with $.Params.url_video }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}">
{{ i18n "btn_video" }}
</a>
{{ end }}
{{ with $.Params.url_code }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | absURL }}">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ . | relURL }}">
{{ i18n "btn_code" }}
</a>
{{ end }}
{{ range $.Params.projects }}
{{ with ($.Site.GetPage (printf "project/%s" .)) }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .Permalink }}">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .RelPermalink }}">
{{ i18n "btn_project" }}
</a>
{{ else }}
{{ errorf "The `projects` parameter in `content/%s` references a project file, `content/project/%s`, which cannot be found. Please either set `projects = []` or fix the reference." $.File.Path . }}
{{ end }}
{{ end }}
{{ range $.Params.url_custom }}
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .url | absURL }}">
<a class="btn btn-outline-primary my-1 mr-1{{ if $is_list }} btn-sm{{end}}" href="{{ .url | relURL }}">
{{ .name }}
</a>
{{ end }}
@@ -9,7 +9,7 @@
{{ if $header.overlay_img }}
background-image:
{{ if $header.overlay_filter }}linear-gradient(rgba(0, 0, 0, {{ $header.overlay_filter }}), rgba(0, 0, 0, {{ $header.overlay_filter }})), {{ end }}
url('{{ printf "img/%s" $header.overlay_img | absURL}}');
url('{{ printf "img/%s" $header.overlay_img | relURL }}');
{{ end }}
;">
@@ -20,7 +20,7 @@
{{ if $item.overlay_img }}
background-image:
{{ if $item.overlay_filter }}linear-gradient(rgba(0, 0, 0, {{ $item.overlay_filter }}), rgba(0, 0, 0, {{ $item.overlay_filter }})), {{ end }}
url('{{ printf "img/%s" $item.overlay_img | absURL}}');
url('{{ printf "img/%s" $item.overlay_img | relURL }}');
{{ end }}
;">
<div class="container" style="text-align: {{$item.align | default "left"}};">
@@ -10,7 +10,7 @@ <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if gt $posts_len $page.Params.count }}
<p class="view-all">
<a href="{{ ($.Site.GetPage "section" "post").Permalink }}">
<a href="{{ ($.Site.GetPage "section" "post").RelPermalink }}">
{{ i18n "more_posts" | markdownify }}
<i class="fas fa-angle-double-right"></i>
</a>
@@ -54,7 +54,7 @@ <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
<span class="project-title">
{{ if .Content }}
<a href="{{ .Permalink }}">
<a href="{{ .RelPermalink }}">
{{ else }}
{{ with .Params.external_link }}<a href="{{ . }}" target="_blank" rel="noopener">{{ end }}
{{ end }}
@@ -71,7 +71,7 @@ <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
<div class="row isotope projects-container js-layout-masonry">
{{ range $project := where $.Site.RegularPages "Type" ($page.Params.folder | default "project") }}
{{ $.Scratch.Set "project_url" $project.Permalink }}
{{ $.Scratch.Set "project_url" $project.RelPermalink }}
{{ $.Scratch.Set "target" "" }}
{{ if $project.Params.external_link }}
{{ $.Scratch.Set "project_url" $project.Params.external_link }}
@@ -9,7 +9,7 @@ <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if gt $pubs_len $page.Params.count }}
<p class="view-all">
<a href="{{ ($.Site.GetPage "section" "publication").Permalink }}">
<a href="{{ ($.Site.GetPage "section" "publication").RelPermalink }}">
{{ i18n "more_publications" | markdownify }}
<i class="fas fa-angle-double-right"></i>
</a>
@@ -24,7 +24,7 @@ <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ $tagCount := len $taxonomy.Pages }}
{{ $weight := div (sub (math.Log $tagCount) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
{{ $fontSize := add $fontSmall (mul (sub $fontBig $fontSmall) $weight) }}
<a href="{{ ($.Site.GetPage (printf "tags/%s" $name)).Permalink }}" style="font-size:{{ $fontSize }}rem">{{ $name }}</a>
<a href="{{ ($.Site.GetPage (printf "tags/%s" $name)).RelPermalink }}" style="font-size:{{ $fontSize }}rem">{{ $name }}</a>
{{ end }}
</div>
{{ end }}
@@ -9,7 +9,7 @@ <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if gt $talks_len $page.Params.count }}
<p class="view-all">
<a href="{{ ($.Site.GetPage "section" "talk").Permalink }}">
<a href="{{ ($.Site.GetPage "section" "talk").RelPermalink }}">
{{ i18n "more_talks" | markdownify }}
<i class="fas fa-angle-double-right"></i>
</a>
Oops, something went wrong.

0 comments on commit 6ef1908

Please sign in to comment.