Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

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

Closed
tylerlwsmith wants to merge 1 commit intotypeorm:masterfrom
tylerlwsmith:vue-router-history
Closed

Change Vue Router's mode from 'hash' to 'history'#36
tylerlwsmith wants to merge 1 commit intotypeorm:masterfrom
tylerlwsmith:vue-router-history

Conversation

@tylerlwsmith
Copy link
Copy Markdown

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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant