Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Vue Router's mode from 'hash' to 'history' #36

Closed
wants to merge 1 commit into from

Conversation

tylerlwsmith
Copy link

This pull request changes Vue Router's mode from the default of "hash" to "history." This solves open issue #30 without needing to completely rebuild the documentation as a static site. In effect, this will change the URL structure from https://typeorm.io/#/entities/entity-columns to https://typeorm.io/entities#entity-columns. This URL structure will allow Google to index inner pages of the documentation.

Google currently doesn't index hashed routes, which means it can only see the homepage of the TypeORM documentation. Changing Vue Router to use history mode will allow Google to index the documentation's inner pages, making it easier for TypeORM users to find relevant documentation directly from Google searches.

These changes also include a backwards compatibility layer in the Router to ensure that current documentation links continue to work. You can test this by going to /#/entities/entity-columns and seeing the redirect to /entities#entity-columns.

The following changes were made:

  1. The router mode changed from "hash" to "history" in index.js.
  2. A beforeEach() instance method was added to the router to handle redirecting the current URL structure to the new URL structure in index.js.
  3. Changed all instances of the word fragment to hash in MarkdownReader.js because the URL structure now uses a hash.
  4. Removed links-replacer and other-page-links-replacer converter extensions because the converter uses hashes by default.
  5. Changed DocumentPage.js to use hash instead of fragment.

In addition to improving SEO, these changes will also fix header anchors on the homepage.

Thank you for taking the time to review this, I really appreciate it. This is my first open source pull request and I hope it's helpful.

@tylerlwsmith
Copy link
Author

After testing a bit further, I realized this change doesn't gracefully handle 404 errors. There's a proposal to support single page applications on GitHub pages, but it doesn't look like it's implemented yet.

I'm closing this pull request for now. I'd can reopen if GitHub pages supports this SPAs in the future or the documentation moved to a site like Netlify that's set up to handle single page apps.

giladgd added a commit to giladgd/typeorm.github.io that referenced this pull request Mar 24, 2022
…arch engine indexing

In order to support loading a deep url without getting a 404 error, a custom 404.html page is implemented to redirect back to index.html which uses history api to load the original url without a refresh.
Based on typeorm#36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant