Hugo invitation link returns to the website (Already gone through posted solutions)

Hello everyone,
I’m having trouble with signup to netlify cms. I’ve followed Hugo netlify cms tutorial but having an issue. According to doc, I should have add a script to my index.html page. But my theme has no index.html page, so I’ve added this to my partial html pages but didn’t work.

When I invite myself to the CMS, I click invitation link and instead of signup popup, the link redirect me to the homepage of my website. I see some token on the URL but signup part does not show up.

After some research I read this post
Tomrutgers has prepared clean instructions but 1. solutions wasn’t for me since I don’t have index.html. 2. solution was not also solved my problem since I am a free tier user. I can’t edit mail templates.

Here is my github repo, How can I add identity script properly?

How about creating an empty index.html, with just a standard html template, and the script posted in this comment? It would redirect any traffic coming from the email templates to the admin page, to which you can then add the identity widget.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title></title>

</head>

<body>
  <script type="text/javascript">
    if (window.location.hash.includes('_token=')) {
      window.location.replace('/admin/' + window.location.hash)
    }
  </script>
</body>
</html>

Hello @tomrutgers
In my file structure, where exactly should I put this index.html file? under layouts?

I’ve created a index.html under layouts/ folder with you posted on the comment.
Now I have 2 problem:

  1. Since I created a index.html now homepage is a blank white screen. I don’t see my theme’s homepage
  2. While I can correctly set up a password through the invitation link, after this step I get “branch not found” error. I’m not sure why this is happening.

UPDATE:
Issue 2 has been solved by editing config.yaml. I’ve changed branch to main to master.
However issue 1 still remain. Since I’m created layouts/index.html, homepage is blank white screen

Hey @mustafasakalli,

Since your theme uses a baseof.html: hugo-theme-stack/baseof.html at 9f734a064703eab8c31f2b1bbc4a434be7574961 · CaiJimmy/hugo-theme-stack · GitHub with {{ block "main" .}}, if you add anything outside that, it won’t work.

You would have to change your index.html to:

{{ define "main" }}
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
<script type="text/javascript">
    if (window.location.hash.includes('_token=')) {
      window.location.replace('/admin/' + window.location.hash)
    }
</script>
{{ end }}