gobuffalo / docs

The source for the Buffalo website
https://gobuffalo.io
MIT License
112 stars 153 forks source link

could it be possible we make this path transition seamlessly? #628

Closed sio4 closed 2 years ago

sio4 commented 2 years ago

Related to this PR: maybe consider redirecting old doc links to the new doc URLs at least until search engines re-index (or redirect all /en/docs/* to documents home if that is difficult). Currently if you search Google for Gobuffalo docs there are a lot of 404s

from https://github.com/gobuffalo/docs/pull/627#issuecomment-1088193599 by @saurori

Yeah, I agree. Actually, I am not a Hugo person but a Jekyll lover, and Jekyll has a plugin called jekyll-redirect-from which supports a directive called redirect_from for front-matter. With this directive and document template with the canonical link for SEO, seamless moving was possible when I moved my blog.

I quickly search for it, and I found there was a discussion about it before. [1] Do you know how aliases directive works? I think it could be a solution for this issue.

[1] https://discourse.gohugo.io/t/url-redirect-forwarding/4689/19

sio4 commented 2 years ago

I quickly tested on this issue:

I modified this sample file content/documentation/getting_started/d/integrations.md as below:

---
name: Tooling Integration
seoDescription: "Tooling Integration"
seoKeywords: 
  - "tooling"
  - "ide"
  - "integration"
  - "buffalo"
  - "bash"
  - "zsh"
  - "go"
  - "golang"
aliases:
  - /en/docs/getting-started/integrations
---
<...>

(added the last two lines: aliases)

Then for the test server, it automatically redirects without sending the old content but I think it is not the case for having a proxy like Nginx for the contents.

$ curl -v http://localhost:1313/en/docs/getting-started/integrations
*   Trying 127.0.0.1:1313...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1313 (#0)
> GET /en/docs/getting-started/integrations HTTP/1.1
> Host: localhost:1313
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Location: integrations/
< Date: Tue, 05 Apr 2022 10:42:51 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

and checked the generated file for the old URL, public/en/docs/getting-started/integrations/index.html, is as below:

<!doctype html>
<html>
<head>
<title>https://gobuffalo.io/documentation/getting_started/integrations/</title>
<link rel=canonical href=https://gobuffalo.io/documentation/getting_started/integrations/>
<meta name=robots content="noindex">
<meta charset=utf-8>
<meta http-equiv=refresh content="0; url=https://gobuffalo.io/documentation/getting_started/integrations/">
</head>
</html>

(newlines are added by myself for readability)

It automatically generates the canonical link and meta-refresh so it could be the best solution for this issue, even though we have to add all the aliases :-p

sio4 commented 2 years ago
$ find content/ -type f |wc -l
89

not a big deal.

@paganotoni, Do you have any concerns about this approach or another intention of not to do this while you configured the new URL scheme? Otherwise, I will working on it.

paganotoni commented 2 years ago

This is awesome @sio4! no objections on my side. 👏

sio4 commented 2 years ago

Ok, then will file a PR tomorrow!