Add dns-prefetch in page header?

Hi everybody,

Excuse my poor English.

I’m an SEO analyst, I’m trying to develop my first site with Hugo and I’ve noticed a lack (maybe?).

I understand that the dns-prefetch has not been added in the webpage header for all the links needed to render the page and outbound links.

Thx :slight_smile:

That’s not a Hugo issue. Add what you want to prefetch inside <head></head>

1 Like

This does not make a very big difference (for small pages).

I created my own render-link hook with adding dns prefetch for outgoing links of the page.
If you go to the next page, dns is resolved.

Sorry for the delay in the response.

If you have made your own custom hook it means that I’m not the only one to think this way :slight_smile:

yes, render-link.html looks like

{{- $url := (urls.Parse .Destination) -}}
{{- $internal := site.GetPage .Destination -}}
{{- $fragment := $url.Fragment -}}
{{- with $fragment -}}{{ $fragment = printf "#%s" $fragment }}{{- end -}}
{{- $destination := printf "%s%s" (or $internal.RelPermalink .Destination) $fragment -}}
{{- if  not $internal -}}<link rel=dns-prefetch href=//{{ $url.Host }} /> {{- end -}}
<a href="{{ $destination | safeURL }}"
   {{ with or .Title $internal.LinkTitle .Text }} title="{{ . }}" {{ end }}
   {{ if not $internal }} rel="noopener external" {{ end }}>
  {{ or .Text .Title $internal.LinkTitle | safeHTML }}

stripped down to the bones

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.