1

I am working on some static pages using Nuxt.js (MPA). Whenever I run the generate command, all <nuxt-link> URLs start from root, i.e /. For example, my structure is:

pages
    |
     - index.vue
     - policy.vue

And in index.vue I have linked policy page as:

<nuxt-link to="policy.html"> Policy </nuxt-link>

which results in /policy.html instead of policy.html.

1
  • Link to a file, regardless if it is root relative (/policy.html) or relative (policy.html) is not a valid prop for nuxt-link component, which is an alias for router-link. Instead, a path (without extension) or route name should be passed. See more in router-link API reference Commented Dec 2, 2018 at 20:34

1 Answer 1

1

You need to replace policy.html by a path so like this

Wrong : <nuxt-link to="policy.html"> Policy </nuxt-link>

Right : <nuxt-link to="/policy"> Policy </nuxt-link>

Check the docs for more informations Nuxt Link

Sign up to request clarification or add additional context in comments.

2 Comments

In both cases (wrong/right) it would take path from root. i.e.` xyz.com/policy/` and would fail if site is hosted on xyz.com/test/
If you want a custom url like this you need to specify the root in the nuxt.config.js like this export default { router: { base: '/test/' } } More infos : here nuxtjs.org/api/configuration-router

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.