alanorth / hugo-theme-bootstrap4-blog

A blogging-centric Bootstrap v4 theme for the Hugo static site generator.
Other
204 stars 132 forks source link

Create relative links only #133

Open fte378 opened 4 years ago

fte378 commented 4 years ago

The distributed web slowly becomes a reality and that's good in my opinion when you take the current hysteria and the rise of censorship into account.

I'm currently in the process of converting my blog so that it will be usable on IPFS (https://ipfs.io/). The main problem is converting all links to be relative to the current page.

In general this can be done with relativeURLs = true in config.toml but:

What are the advantages of relative URLs?

What's your opinion? Is it worth to go this direction with the theme? I personally end up overwriting most of the theme but I'm o.k. with this.

alanorth commented 4 years ago

@fte378 apologies for the late reply. The distributed web is a good thing and I support your exploration in that area, but I have been thinking about this a little bit in the theme context and I'm still unsure. When building the theme I consciously used the absURL template function because I thought absolute was better or more exact somehow. It's only a handful of places actually:

$ grep -rsI absURL layouts/*
layouts/_default/single.html:    "url": {{ . | absURL }}
layouts/_default/baseof.html:        <h1 class="blog-title" dir="auto"><a href="{{ .Site.BaseURL | absURL }}" rel="home">{{ .Site.Title | safeHTML }}</a></h1>
layouts/partials/sidebar.html:      <li><a href="{{ .URL | absURL }}">{{ .Name }}</a></li>
layouts/partials/cookie-consent.html:        policyUrl: {{ . | absURL }},
layouts/robots.txt:Sitemap: {{ "sitemap.xml" | absURL }}

Curiously the 404 template uses relURL:

$ grep -rsI relURL layouts/*
layouts/404.html:  <p>Page not found. Go back <a href="{{ "/" | relURL }}">home</a>.</p>

How does the site-wide relativeURLs setting affect these template functions?

fte378 commented 4 years ago

The places where absUrl is used are not touched again by Hugo. I had to replace them. I'm already done with the conversion since mid-April and it works well.

I even wrote an article about it (German but I think it's understandable even through a translator): https://frank.tegtmeyer.net/2020/04/ipfs-und-mein-blog/

I also used absolute URLs a lot to avoid confusion and downgrading in search engines but I got to a state of mind where I don't care anymore about search engines. Good content eventually wins even when it does nothing regarding SEO.

For me the possibility to "mount" the blog at any URL (including offline use) is a plus.

For the conversion I had to remove the SEO stuff from the headers - there were some things (I think with the images) which I could not get to generate relative URLs.

The problem with the theme is that other users may have completely opposite views about the topic.

Regards, Frank