Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create relative links only #133

Open
fte378 opened this issue Apr 12, 2020 · 2 comments
Open

Create relative links only #133

fte378 opened this issue Apr 12, 2020 · 2 comments

Comments

@fte378
Copy link
Contributor

fte378 commented Apr 12, 2020

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:

  • embedded styles with url() are not handled correctly - this happens for my image galleries - I handled it with giving only relative image URLs to the gallery
  • the theme has lots of places where absolute URLs get generated - these are not converted back by Hugo

What are the advantages of relative URLs?

  • you can view the page on IPFS on any gateway (dweb.link, ipfs.io, cloudflare-ipfs.com, your local IPFS gateway on localhost etc)
  • if you eliminate all external dependencies you can even pack you site on a USB stick an view it locally - something what static web pages nearly always were useful for

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
Copy link
Owner

alanorth commented May 26, 2020

@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
Copy link
Contributor Author

fte378 commented May 26, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants