question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Link to static html is not working

See original GitHub issue

Hello,

I’d like to create a link to a static html file but the link is not working.

The reason that I want to do is that I want to use netlify-cms for my gatsby blog. It uses a static html page to launch. The static files are located in /static/admin/ in gatsby project.

Assume that the site url is https://www.site.com. Then, I can access the admin page with this url: https://www.site.com/admin/.

Now I want to create a link in my gatsby blog to that admin page. I will link it using relative path: ‘/admin/’

It looks something like this:

class Page extends React.Components {
  render() {
    return (
      <a href="/admin/">Link to admin page</a>
    );
  }
}

If I click the link which is rendered from that code, I can see 404 page. The console says that: A page wasn’t found for “/admin/” The console message is written from here.

Can I do some schemes to bypass this happening?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
dustinhortoncommented, Apr 24, 2018

I’ve been doing a little Link component that composes a gatsby-link component and an a tag:

import GatsbyLink from 'gatsby-link'
import PropTypes from 'prop-types'
import React from 'react'

export default function Link(props) {
  const { href, to, ...others } = props

  if (to) {
    return (
      <GatsbyLink {...others} to={to} />
    )
  }

  return (
    <a {...others} href={href} target="_blank" />
  )
}

Link.propTypes = {
  href: PropTypes.string,
  to: PropTypes.string,
}
1reaction
WhiteAbeLincolncommented, Jun 11, 2019

I’m also experiencing the same issue as @hackhat. A plain a tag still does the push-state, which means I’m unable to link to my Netlify CMS page from my site. If I add the target=“_blank” attribute, the link works as expected

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML a link not working when linked to other pages on site
I have played around with the paths, tried typing the name of the file explicitly, and have found that links to external sites...
Read more >
VS 2013 Browser Link not working on static HTML file
I'm trying to do it on an ASP.NET Empty Web Site... enter image description here. Running VS 2013 as administrator, updated web.config file,...
Read more >
How Do You Serve Static Files in Flask? - Sentry
You need to create a folder called static in your application's root directory to store all your static files. Then you can use...
Read more >
How to manage static files (e.g. images, JavaScript, CSS)
In your templates, use the static template tag to build the URL for the given relative path using the configured STATICFILES_STORAGE . {%...
Read more >
Working with Static Files - ASP.NET Core Documentation
Static files, such as HTML, CSS, image, and JavaScript, are assets that an ASP.NET Core app can ... The static file module provides...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found