Skip to content

Commit 937adb8

Browse files
authored
Version: document how to change the version slug and expose it to everyone (#12096)
Closes #11971
1 parent e951202 commit 937adb8

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

docs/user/faq.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ We have documented how to set this up in :doc:`/reference/robots`.
8888
How do I change the version slug of my project?
8989
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9090

91-
We don't support allowing folks to change the slug for their versions.
92-
But you can rename the branch/tag to achieve this.
93-
If that isn't enough,
94-
you can request the change sending an email to [email protected].
91+
You can change the slug of your versions from the versions tab of your project,
92+
see :ref:`versions:Version URL identifier (slug)` for more information.
9593

9694

9795
What commit of Read the Docs is in production?

docs/user/versions.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,39 @@ all of the artifacts of your version will be deleted and a ``404 Not Found`` pag
8888

8989
You can change the state for each version of your documentation in the :guilabel:`Versions` tab of your project.
9090

91+
Version URL identifier (slug)
92+
-----------------------------
93+
94+
Each version of your project has a unique URL identifier (slug).
95+
This identifier is used to reference the version in your documentation, :term:`dashboard`, and :doc:`API </api/index>`.
96+
97+
A version slug is automatically generated from the name of the branch or tag in your repository,
98+
some special characters like spaces and ``/`` are replaced with a dash (``-``), and the name is lowercased.
99+
If the resulting slug collides with another one, a suffix is added (``_a``, ``_b``, etc.).
100+
101+
You can change the slug of a version in :ref:`the versions tab of your project <versions:Managing your versions>`,
102+
but you should take the following into account:
103+
104+
- Changing the slug of an active version will result on its previous documentation being deleted, and a new build being triggered.
105+
Be careful when renaming active versions, specially old ones that might not build anymore.
106+
- Any URL referencing your version with the old slug will return a ``404 Not Found`` page.
107+
You can use :ref:`an exact redirect <user-defined-redirects:Redirecting an old version to a new one>` to redirect users to the new URL,
108+
- You may still see the original name of the version in some places,
109+
as changing the slug only affects the URL used in your documentation and how the APIs identify that version.
110+
`We are considering adding another field to be used for display in the future <https://github.com/readthedocs/readthedocs.org/issues/11979>`__.
111+
- Sorting of versions in the version selector is done based on the slug,
112+
changing the slug of a version may change the order in which they are shown to your users.
113+
`We are considering adding another field to be used for sorting in the future <https://github.com/readthedocs/readthedocs.org/issues/11979>`__.
114+
- You can't change the slug of versions that are managed by Read the Docs, like ``latest`` and ``stable``.
115+
- Slugs must be unique for each version of your project.
116+
- The slug can contain lowercase letters, numbers, dashes (``-``), underscores (``_``) and dots (``.``).
117+
If you try to use a slug that contains any other character, you'll get an error message with a suggestion of a valid slug.
118+
119+
.. warning::
120+
121+
Changing the slug of an active version will result on its previous documentation being deleted, and a new build being triggered.
122+
Be careful when renaming active versions, specially old ones that might not build anymore.
123+
91124
Disabling versioning completely
92125
-------------------------------
93126

readthedocs/builds/forms.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from readthedocs.builds.models import Version
2222
from readthedocs.builds.models import VersionAutomationRule
2323
from readthedocs.builds.version_slug import generate_version_slug
24-
from readthedocs.projects.models import Feature
2524

2625

2726
class VersionForm(forms.ModelForm):
@@ -74,9 +73,6 @@ def __init__(self, *args, **kwargs):
7473
if self.instance and self.instance.machine:
7574
self.fields["slug"].disabled = True
7675

77-
if not self.project.has_feature(Feature.ALLOW_CHANGING_VERSION_SLUG):
78-
self.fields.pop("slug")
79-
8076
self.helper = FormHelper()
8177
self.helper.layout = Layout(*field_sets)
8278
# We need to know if the version was active before the update.

readthedocs/projects/models.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,6 @@ def add_features(sender, **kwargs):
19121912
USE_PROXIED_APIS_WITH_PREFIX = "use_proxied_apis_with_prefix"
19131913
ALLOW_VERSION_WARNING_BANNER = "allow_version_warning_banner"
19141914
DONT_SYNC_WITH_REMOTE_REPO = "dont_sync_with_remote_repo"
1915-
ALLOW_CHANGING_VERSION_SLUG = "allow_changing_version_slug"
19161915

19171916
# Versions sync related features
19181917
SKIP_SYNC_TAGS = "skip_sync_tags"
@@ -1964,10 +1963,6 @@ def add_features(sender, **kwargs):
19641963
DONT_SYNC_WITH_REMOTE_REPO,
19651964
_("Remote repository: Don't keep project in sync with remote repository."),
19661965
),
1967-
(
1968-
ALLOW_CHANGING_VERSION_SLUG,
1969-
_("Dashboard: Allow changing the version slug."),
1970-
),
19711966
# Versions sync related features
19721967
(
19731968
SKIP_SYNC_BRANCHES,

readthedocs/rtd_tests/tests/test_build_forms.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@
88
from readthedocs.builds.forms import VersionForm
99
from readthedocs.builds.models import Version
1010
from readthedocs.projects.constants import PRIVATE, PUBLIC
11-
from readthedocs.projects.models import Feature, HTMLFile, Project
11+
from readthedocs.projects.models import HTMLFile, Project
1212

1313

1414
class TestVersionForm(TestCase):
1515
def setUp(self):
1616
self.user = get(User)
1717
self.project = get(Project, users=(self.user,), slug="project")
18-
get(
19-
Feature,
20-
feature_id=Feature.ALLOW_CHANGING_VERSION_SLUG,
21-
projects=[self.project],
22-
)
2318

2419
@override_settings(ALLOW_PRIVATE_REPOS=False)
2520
def test_default_version_is_active(self):

0 commit comments

Comments
 (0)