nextflow-io / website

Nextflow public web site
6 stars 68 forks source link

Redirect old blog posts #321

Closed MythicalFish closed 2 weeks ago

netlify[bot] commented 2 weeks ago

Deploy Preview for nextflow-staging ready!

Name Link
Latest commit d9616b32684372ca52af3127205cf1c581e28c6c
Latest deploy log https://app.netlify.com/sites/nextflow-staging/deploys/670fedbd69bedc000896bf57
Deploy Preview https://deploy-preview-321--nextflow-staging.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 75 (🔴 down 2 from production)
Accessibility: 95 (no change from production)
Best Practices: 83 (no change from production)
SEO: 85 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

ewels commented 2 weeks ago

Hate to tell you this, but this won't work 🙈

Deployment previews run with Netlify, but the live site runs via some kind of vanilla AWS s3 hosting setup that @pditommaso runs.

I'm not sure how to do redirects from there, or if it's even possible. That's why there's stuff like https://nextflow.io/slack-invite.html that does client-side redirection.

MythicalFish commented 2 weeks ago

Hmm tricky problem... I hadn't thought much beyond just generating the list of redirects honestly

MythicalFish commented 2 weeks ago

I'm assuming this is being provided via CloudFront? If so we should be able to add a redirect function via the AWS console: https://www.edge-cloud.net/2023/03/20/http-redirect-with-cloudfront/

Here is the handler (I tested the paths, should be good to go): Edit: updated the script to add some other unrelated redirects requested by Phil.

const paths = [
  "/blog/2014/nextflow-meets-docker.html",
  "/blog/2014/share-nextflow-pipelines-with-github.html",
  "/blog/2014/using-docker-in-hpc-cluster.html",
  "/blog/2015/innovation-in-science-the-story-behind-nextflow.html",
  "/blog/2015/introducing-nextflow-console.html",
  "/blog/2015/mpi-like-execution-with-nextflow.html",
  "/blog/2015/the-impact-of-docker-on-genomic-pipelines.html",
  "/blog/2016/best-practice-for-reproducibility.html",
  "/blog/2016/deploy-in-the-cloud-at-snap-of-a-finger.html",
  "/blog/2016/developing-bioinformatics-pipeline-across-multiple-environments.html",
  "/blog/2016/docker-for-dunces-nextflow-for-nunces.html",
  "/blog/2016/enabling-elastic-computing-nextflow.html",
  "/blog/2016/error-recovery-and-automatic-resources-management.html",
  "/blog/2016/more-fun-containers-hpc.html",
  "/blog/2017/caw-and-singularity.html",
  "/blog/2017/nextflow-and-cwl.html",
  "/blog/2017/nextflow-hack17.html",
  "/blog/2017/nextflow-nature-biotech-paper.html",
  "/blog/2017/nextflow-workshop.html",
  "/blog/2017/scaling-with-aws-batch.html",
  "/blog/2018/bringing-nextflow-to-google-cloud-wuxinextcode.html",
  "/blog/2018/clarification-about-nextflow-license.html",
  "/blog/2018/conda-support-has-landed.html",
  "/blog/2018/goodbye-zero-hello-apache.html",
  "/blog/2018/nextflow-meets-dockstore.html",
  "/blog/2018/nextflow-turns-5.html",
  "/blog/2019/demystifying-nextflow-resume.html",
  "/blog/2019/easy-provenance-report.html",
  "/blog/2019/one-more-step-towards-modules.html",
  "/blog/2019/release-19.03.0-edge.html",
  "/blog/2019/release-19.04.0-stable.html",
  "/blog/2019/troubleshooting-nextflow-resume.html",
  "/blog/2020/cli-docs-release.html",
  "/blog/2020/dsl2-is-here.html",
  "/blog/2020/groovy3-syntax-sugar.html",
  "/blog/2020/learning-nextflow-in-2020.html",
  "/blog/2021/5-more-tips-for-nextflow-user-on-hpc.html",
  "/blog/2021/5_tips_for_hpc_users.html",
  "/blog/2021/configure-git-repositories-with-nextflow.html",
  "/blog/2021/introducing-nextflow-for-azure-batch.html",
  "/blog/2021/nextflow-developer-environment.html",
  "/blog/2021/nextflow-sql-support.html",
  "/blog/2021/setup-nextflow-on-windows.html",
  "/blog/2022/caching-behavior-analysis.html",
  "/blog/2022/czi-mentorship-round-1.html",
  "/blog/2022/deploy-nextflow-pipelines-with-google-cloud-batch.html",
  "/blog/2022/evolution-of-nextflow-runtime.html",
  "/blog/2022/learn-nextflow-in-2022.html",
  "/blog/2022/nextflow-is-moving-to-slack.html",
  "/blog/2022/nextflow-summit-2022-recap.html",
  "/blog/2022/nextflow-summit-call-for-abstracts.html",
  "/blog/2022/rethinking-containers-for-cloud-native-pipelines.html",
  "/blog/2022/turbocharging-nextflow-with-fig.html",
  "/blog/2023/a-nextflow-docker-murder-mystery-the-mysterious-case-of-the-oom-killer.html",
  "/blog/2023/best-practices-deploying-pipelines-with-hpc-workload-managers.html",
  "/blog/2023/celebrating-our-largest-international-training-event-and-hackathon-to-date.html",
  "/blog/2023/community-forum.html",
  "/blog/2023/czi-mentorship-round-2.html",
  "/blog/2023/czi-mentorship-round-3.html",
  "/blog/2023/geraldine-van-der-auwera-joins-seqera.html",
  "/blog/2023/introducing-nextflow-ambassador-program.html",
  "/blog/2023/learn-nextflow-in-2023.html",
  "/blog/2023/nextflow-goes-to-university.html",
  "/blog/2023/nextflow-summit-2023-recap.html",
  "/blog/2023/nextflow-with-gbatch.html",
  "/blog/2023/reflecting-on-ten-years-of-nextflow-awesomeness.html",
  "/blog/2023/selecting-the-right-storage-architecture-for-your-nextflow-pipelines.html",
  "/blog/2023/the-state-of-kubernetes-in-nextflow.html",
  "/blog/2024/addressing-bioinformatics-core-challenges.html",
  "/blog/2024/ambassador-second-call.html",
  "/blog/2024/better-support-through-community-forum-2024.html",
  "/blog/2024/bioinformatics-growth-in-turkiye.html",
  "/blog/2024/empowering-bioinformatics-mentoring.html",
  "/blog/2024/experimental-cleanup-with-nf-boost.html",
  "/blog/2024/how_i_became_a_nextflow_ambassador.html",
  "/blog/2024/nextflow-24.04-highlights.html",
  "/blog/2024/nextflow-colored-logs.html",
  "/blog/2024/nextflow-nf-core-ancient-env-dna.html",
  "/blog/2024/nf-schema.html",
  "/blog/2024/nf-test-in-nf-core.html",
  "/blog/2024/nxf-nf-core-workshop-kogo.html",
  "/blog/2024/optimizing-nextflow-for-hpc-and-cloud-at-scale.html",
  "/blog/2024/reflecting-ambassador-collaboration.html",
  "/blog/2024/reflections-on-nextflow-mentorship.html",
  "/blog/2024/training-local-site.html",
  "/blog/2024/welcome_ambassadors_20242.html"
]

const otherRedirects = {
  "/vscode": "https://marketplace.visualstudio.com/items?itemName=nextflow.nextflow",
  "/openvsx": "https://open-vsx.org/extension/nextflow/nextflow"
}

function handler(event) {
  var request = event.request;
  var uri = request.uri;

  for (const path of paths) {
    if (uri === path) {

      let newSlug = path.replace('/blog/', '');
      newSlug = newSlug.replace('.html', '');
      newSlug = newSlug.split('/')[1]
      const newURL = `https://seqera.io/blog/${newSlug}`;

      return {
        statusCode: 301,
        statusDescription: 'Moved Permanently',
        headers: {
          'location': { value: newURL }
        }
      };
    }
  }

  if (otherRedirects[uri]) {
    return {
      statusCode: 301,
      statusDescription: 'Moved Permanently',
      headers: {
        'location': { value: otherRedirects[uri] }
      }
    };
  }

  return request;
}

cc @pditommaso

bebosudo commented 2 weeks ago

I ended up rewriting the Cloudfront function

```js // Cloudfront functions don't seem to support Sets nor the URL constructor, so keeping the ?query // and #hash from the original URL is a more cumbersome than it should be. // See https://github.com/nextflow-io/website/pull/321 const otherRedirects = { "/vscode": "https://marketplace.visualstudio.com/items?itemName=nextflow.nextflow", "/openvsx": "https://open-vsx.org/extension/nextflow/nextflow", "/blog.html": "https://seqera.io/blog/tag-nextflow/", } function handler(event) { var uri = event.request.uri.split("?")[0].split("#")[0]; // Remove whatever comes after .html (?query and #fragment parts) // var blogUri = `${uri.split('.html')[0]}.html`; var newurl = ""; // First check if the URI is in the list of other redirects if (uri in otherRedirects) { newurl = otherRedirects[uri]; } // Check if the URI is a blogpost URL else if (uri.startsWith("/blog/") && uri.endsWith(".html")) { // If so, redirect to the new blogpost URL on seqera.io without the year nor the .html // extension; the query and fragment input URL parts are also ignored. newurl = `https://seqera.io/blog/${uri.split('/').pop().split('.html')[0]}`; } // If the URI is not in the list of URIs to be redirected, let the request pass through else { return event.request; } var response = { statusCode: 301, statusDescription: 'Moved Permanently', headers: { "location": { "value": newurl } } } return response; } ```

Before doing so I tested on one of the documents /blog/2014/benchmarking-docker-hpc-cluster-draft.html if a <meta http-equiv="refresh" content="0; url='https://seqera.io/blog/'"/> was enough instead of touching cloudfront settings, but I ended up bricking the blog page somehow? I'll reach out in the team documentation channel on how to get that fixed.

edit: updated redirect function to redirect any blog post, not just a selection

bebosudo commented 2 weeks ago

I forgot to add that I put that Cloudfront function on a temporary Cloudfront distribution to avoid disrupting the existing one any more, and you can test it with any of the blog posts in the code, e.g.: https://d1t7mnzngy878e.cloudfront.net/blog/2014/nextflow-meets-docker.html which will redirect you to https://seqera.io/blog/nextflow-meets-docker/

MythicalFish commented 2 weeks ago

Awesome, thanks v much @bebosudo ! Looks like it works on the temp distribution 👍

bebosudo commented 2 weeks ago

I applied the new Cloudfront function to the official CF distribution, now links are being redirected by cloudfront! e.g. https://nextflow.io/blog/2014/nextflow-meets-docker.html -> https://seqera.io/blog/nextflow-meets-docker/

I think this PR can be closed?

MythicalFish commented 2 weeks ago

Fantastic, thanks Alberto! And yes we can close this now 👍