0

My folders structure:

src/routes/[lang]/
├── +layout.svelte
├── +page.svelte        
├── +page.server.ts    
└── [category]/
    ├── +page.svelte
    └── +page.server.ts

The problem is that if I am opening page /en/smth, it is always triggering [lang] folder "index" files +page.svelte and +page.server.svelte.

How to make /en page logic not to trigger at /en/smth page?

2 Answers 2

1

If I understand correctly, when visiting /en/smth, the content from +layout.svelte of the [lang] folder is appearing on the category page and you don't want it there.

This is because SvelteKit layouts are inherited hierarchically. The [lang]/[category] routes were inheriting the layout from their parent [lang] directory.

A solution here is to create a layout reset file [email protected] in the [lang]/[category] directory. This resets the layout inheritance chain (@ symbol). It tells SvelteKit to break the inheritance from parent layouts and start fresh.

With that, you should have:

- /en→ Uses +layout.svelte → Shows its content

- /en/smth → Uses [lang]/[category]/[email protected] → Resets layout inheritance → No content from the [lang] layout.

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

1 Comment

no. you have read not carefully. it is always triggering [lang] folder "index" files +page.svelte and +page.server.svelte
1

Problem was solved by myself. I have fallback to /[lang] route if the page is not found. but at localhost my chrome dev tools during loading of /[lang]/[category] page tried to get the page \.well-known\appspecific\com.chrome.devtools.json and it was returning 404 and console always was showing double loading of /[lang] route.

Comments

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.