termux / termux.github.io

The main termux site and help pages.
https://termux.github.io
883 stars 173 forks source link

Changed: added redirect template #105

Closed thunder-coding closed 1 year ago

agnostic-apollo commented 1 year ago

Following is the index.html generated for https://termux.dev and will be roughly same for other redirected pages. Note that this includes the head.html and footer.html which will then trigger further requests for main.css and minima-social-icons.svg, but they should be cached, so further page loads should not be affected, assuming redirection is for a normal site page, since otherwise there will be a performance hit.

<!DOCTYPE html>
<html lang="en"><head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1"><!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Termux | The main termux site and help pages.</title>
<meta name="generator" content="Jekyll v3.9.3" />
<meta property="og:title" content="Termux" />
<meta property="og:locale" content="en" />
<meta name="description" content="The main termux site and help pages." />
<meta property="og:description" content="The main termux site and help pages." />
<link rel="canonical" href="http://localhost:4000/" />
<meta property="og:url" content="http://localhost:4000/" />
<meta property="og:site_name" content="Termux" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Termux" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","description":"The main termux site and help pages.","headline":"Termux","name":"Termux","url":"http://localhost:4000/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/assets/main.css"><link type="application/atom+xml" rel="alternate" href="http://localhost:4000/feed.xml" title="Termux" /></head>
<body><header class="site-header" role="banner">

  <div class="wrapper"><a class="site-title" rel="author" href="/">Termux</a><nav class="site-nav">
        <input type="checkbox" id="nav-trigger" class="nav-trigger" />
        <label for="nav-trigger">
          <span class="menu-icon">
            <svg viewBox="0 0 18 15" width="18px" height="15px">
              <path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/>
            </svg>
          </span>
        </label>

        <div class="trigger"><a class="page-link" href="/en/docs/index.html">Docs</a><a class="page-link" href="/en/posts/index.html">Posts</a><a class="page-link" href="https://packages.termux.dev">Packages</a><a class="page-link" href="/en/donate">Donate</a><a class="page-link" href="/en/privacy-policy">Privacy Policy</a></div>
      </nav></div>
</header>
<main class="page-content" aria-label="Content">
      <link rel="canonical" href="http://localhost:4000/en/">
<script>location="http://localhost:4000/en/"</script>
<meta http-equiv="refresh" content="0; url=http://localhost:4000/en/">
<meta name="robots" content="noindex">
<h1>Redirecting&hellip;</h1>
<a href="http://localhost:4000/en/">Click here if you are not redirected.</a>

    </main><footer class="site-footer h-card">
  <data class="u-url" href="/"></data>

  <div class="wrapper">

    <h2 class="footer-heading">Termux</h2>

    <div class="footer-col-wrapper">
      <div class="footer-col footer-col-1">
        <ul class="contact-list">
          <li class="p-name"><li><a href="https://github.com/termux/termux.github.io">Site Source</a></li></li></ul>
      </div>

      <div class="footer-col footer-col-2"><ul class="social-media-list"><li><a href="https://github.com/termux"><svg class="svg-icon"><use xlink:href="/assets/minima-social-icons.svg#github"></use></svg> <span class="username">termux</span></a></li><li><a href="https://www.twitter.com/termuxdevs"><svg class="svg-icon"><use xlink:href="/assets/minima-social-icons.svg#twitter"></use></svg> <span class="username">termuxdevs</span></a></li></ul>
</div>

      <div class="footer-col footer-col-3">
        <p>Terminal emulator and Linux environment for Android.</p>
      </div>
    </div>

  </div>

</footer>
</body>

</html>

Following is the current one as per https://github.com/jekyll/jekyll-redirect-from/blob/master/lib/jekyll-redirect-from/redirect.html

<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>Redirecting&hellip;</title>
  <link rel="canonical" href="https://termux.dev/en/">
  <script>location="https://termux.dev/en/"</script>
  <meta http-equiv="refresh" content="0; url=https://termux.dev/en/">
  <meta name="robots" content="noindex">
  <h1>Redirecting&hellip;</h1>
  <a href="https://termux.dev/en/">Click here if you are not redirected.</a>
</html>

Now let's look at the real issues.

  1. Commit message Changed: added redirect template is not following correct uppercase for first letter of description (and also tense) as per current git history. The added needs to be Add. And you are using a layout, not a template. Moreover, if you were "adding" something, the proper commit message type would be Added, not Changed, but you are technically changing something that already exists. A more appropriate message would be Changed: Use custom redirect layout that loads default site layout instead of the one by jekyll-redirect-from. But this still doesn't cover, "why" you made this change. The description should mention your mastodon verification issue, so that anyone who intends to make changes to the file can know that why this was necessary and not to break verification. Check https://github.com/termux/termux-app#for-maintainers-and-contributors for info on conventional commit format that is used by repos I manage.

  2. There needs to be empty line after front matter in redirect.html as per other files.

  3. When you use a layout value in front matter it pulls the current content of the file, and provides it to the specified layout as {{ content }}. So when you use default layout in the redirect.html that contains html content, instead of text content, you are providing it as the body. That's what I meant when I said duplicate html, both redirect.html and default.html have html tags cause they are expected to be standalone pages. What that has done is that

Either fix all the above issues if you want to show header and footer for redirect pages or use following as redirect.html and under if page.redirect.from == "/" add your required mastodon tag.

<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>{{ site.title | escape }} | Redirecting&hellip;</title>
  <link rel="canonical" href="{{ page.redirect.to }}">
  <script>location="{{ page.redirect.to }}"</script>
  <meta http-equiv="refresh" content="0; url={{ page.redirect.to }}">
  <meta name="robots" content="noindex">
  {% if page.redirect.from == "/" -%}
  <h1><a href="{{ page.redirect.to }}">{{ site.title | escape }}</a></h1>
  {%- else -%}
  <h1><a href="{{ site.url }}">{{ site.title | escape }}</a></h1>
  {%- endif %}
  <h2>Redirecting&hellip;</h2>
  <a href="{{ page.redirect.to }}">Click here if you are not redirected.</a>
</html>
thunder-coding commented 1 year ago

You know what https://termux.dev/en works great!